add 'kind' field to user and group models

This commit is contained in:
Min RK
2017-01-26 11:48:20 +01:00
parent d0813cc736
commit 4b6c58292b
2 changed files with 7 additions and 0 deletions

View File

@@ -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 ],
}

View File

@@ -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']
}