mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-10 11:33:01 +00:00
add 'kind' field to user and group models
This commit is contained in:
@@ -89,6 +89,7 @@ class APIHandler(BaseHandler):
|
||||
def user_model(self, user):
|
||||
"""Get the JSON model for a User object"""
|
||||
model = {
|
||||
'kind': 'user',
|
||||
'name': user.name,
|
||||
'admin': user.admin,
|
||||
'groups': [ g.name for g in user.groups ],
|
||||
@@ -105,6 +106,7 @@ class APIHandler(BaseHandler):
|
||||
def group_model(self, group):
|
||||
"""Get the JSON model for a Group object"""
|
||||
return {
|
||||
'kind': 'group',
|
||||
'name': group.name,
|
||||
'users': [ u.name for u in group.users ],
|
||||
}
|
||||
|
@@ -168,6 +168,7 @@ def test_get_users(app):
|
||||
u.pop('last_activity')
|
||||
assert users == [
|
||||
{
|
||||
'kind': 'user',
|
||||
'name': 'admin',
|
||||
'groups': [],
|
||||
'admin': True,
|
||||
@@ -175,6 +176,7 @@ def test_get_users(app):
|
||||
'pending': None,
|
||||
},
|
||||
{
|
||||
'kind': 'user',
|
||||
'name': 'user',
|
||||
'groups': [],
|
||||
'admin': False,
|
||||
@@ -209,6 +211,7 @@ def test_get_user(app):
|
||||
user = r.json()
|
||||
user.pop('last_activity')
|
||||
assert user == {
|
||||
'kind': 'user',
|
||||
'name': name,
|
||||
'groups': [],
|
||||
'admin': False,
|
||||
@@ -570,6 +573,7 @@ def test_groups_list(app):
|
||||
r.raise_for_status()
|
||||
reply = r.json()
|
||||
assert reply == [{
|
||||
'kind': 'group',
|
||||
'name': 'alphaflight',
|
||||
'users': []
|
||||
}]
|
||||
@@ -589,6 +593,7 @@ def test_group_get(app):
|
||||
r.raise_for_status()
|
||||
reply = r.json()
|
||||
assert reply == {
|
||||
'kind': 'group',
|
||||
'name': 'alphaflight',
|
||||
'users': ['sasquatch']
|
||||
}
|
||||
|
Reference in New Issue
Block a user