Skip to content
Snippets Groups Projects
Commit 18715f8a authored by jan.bednarik's avatar jan.bednarik
Browse files

Reduce Author API fields and extend User and Viewer API fields.

parent be91858c
No related branches found
No related tags found
No related merge requests found
......@@ -87,6 +87,8 @@ class User(graphene.ObjectType):
first_name = graphene.String()
last_name = graphene.String()
email = graphene.String()
is_author = graphene.Boolean()
extra = JSONString()
class Meta:
interfaces = (relay.Node, )
......@@ -99,6 +101,8 @@ class User(graphene.ObjectType):
first_name=user.first_name,
last_name=user.last_name,
email=user.email,
is_author=user.is_author,
extra=user.extra,
)
@classmethod
......@@ -113,7 +117,6 @@ class User(graphene.ObjectType):
class Author(graphene.ObjectType):
first_name = graphene.String()
last_name = graphene.String()
openid_uid = graphene.String()
extra = JSONString()
reports = relay.ConnectionField(ReportConnection)
......@@ -126,7 +129,6 @@ class Author(graphene.ObjectType):
id=user.id,
first_name=user.first_name,
last_name=user.last_name,
openid_uid=user.openid_uid,
extra=user.extra,
)
......
......@@ -7,7 +7,6 @@ authors = [
{
'id': 1,
'username': 'Wolf',
'openid_uid': 'Wolf',
'first_name': 'Winston',
'last_name': 'Wolfe',
'is_author': True,
......@@ -16,7 +15,6 @@ authors = [
{
'id': 2,
'username': 'sponge',
'openid_uid': 'sponge',
'first_name': 'Spongebob',
'last_name': 'Squarepants',
'is_author': True,
......@@ -24,7 +22,6 @@ authors = [
{
'id': 3,
'username': 'shaun',
'openid_uid': 'shaun',
'first_name': 'Shaun',
'last_name': 'Sheep',
'is_author': True,
......
......@@ -17,8 +17,7 @@ snapshots['test_all 1'] = {
'extra': '{"movies": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe',
'openidUid': 'Wolf'
'lastName': 'Wolfe'
}
},
{
......@@ -27,8 +26,7 @@ snapshots['test_all 1'] = {
'extra': None,
'firstName': 'Spongebob',
'id': 'QXV0aG9yOjI=',
'lastName': 'Squarepants',
'openidUid': 'sponge'
'lastName': 'Squarepants'
}
},
{
......@@ -37,8 +35,7 @@ snapshots['test_all 1'] = {
'extra': None,
'firstName': 'Shaun',
'id': 'QXV0aG9yOjM=',
'lastName': 'Sheep',
'openidUid': 'shaun'
'lastName': 'Sheep'
}
}
],
......@@ -60,13 +57,17 @@ snapshots['test_first 1'] = {
{
'cursor': 'MQ==',
'node': {
'openidUid': 'Wolf'
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe'
}
},
{
'cursor': 'Mg==',
'node': {
'openidUid': 'sponge'
'firstName': 'Spongebob',
'id': 'QXV0aG9yOjI=',
'lastName': 'Squarepants'
}
}
],
......@@ -88,7 +89,9 @@ snapshots['test_first_after 1'] = {
{
'cursor': 'Mg==',
'node': {
'openidUid': 'sponge'
'firstName': 'Spongebob',
'id': 'QXV0aG9yOjI=',
'lastName': 'Squarepants'
}
}
],
......@@ -127,7 +130,9 @@ snapshots['test_last_before 1'] = {
{
'cursor': 'Mg==',
'node': {
'openidUid': 'sponge'
'firstName': 'Spongebob',
'id': 'QXV0aG9yOjI=',
'lastName': 'Squarepants'
}
}
],
......
......@@ -22,8 +22,7 @@ snapshots['test_author 1'] = {
'extra': '{"x": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjU=',
'lastName': 'Wolfe',
'openidUid': 'TheWolf'
'lastName': 'Wolfe'
}
}
}
......@@ -72,8 +71,10 @@ snapshots['test_user__not_a_viewer 1'] = {
snapshots['test_user 1'] = {
'data': {
'node': {
'extra': '{"e": "mc2"}',
'firstName': 'Albert',
'id': 'VXNlcjo4',
'isAuthor': False,
'lastName': 'Einstein',
'openidUid': 'albert@einstein.id'
}
......
......@@ -36,7 +36,7 @@ snapshots['test_all 1'] = {
'cursor': 'Mg==',
'node': {
'author': {
'extra': None,
'extra': '{"movies": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe'
......@@ -57,7 +57,7 @@ snapshots['test_all 1'] = {
'cursor': 'Mw==',
'node': {
'author': {
'extra': None,
'extra': '{"movies": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe'
......@@ -125,7 +125,7 @@ snapshots['test_highlight 1'] = {
'cursor': 'MQ==',
'node': {
'author': {
'extra': None,
'extra': '{"movies": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe'
......@@ -146,7 +146,7 @@ snapshots['test_highlight 1'] = {
'cursor': 'Mg==',
'node': {
'author': {
'extra': None,
'extra': '{"movies": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe'
......
......@@ -17,8 +17,10 @@ snapshots['test_authenticated 1'] = {
'data': {
'viewer': {
'email': 'winston@wolfe.com',
'extra': '{"caliber": 45}',
'firstName': 'Winston',
'id': 'VXNlcjox',
'isAuthor': True,
'lastName': 'Wolfe',
'openidUid': 'TheWolf'
}
......
......@@ -21,7 +21,6 @@ def test_all(client, snapshot):
id
firstName
lastName
openidUid
extra
}
}
......@@ -46,7 +45,9 @@ def test_first(client, snapshot):
edges {
cursor
node {
openidUid
id
firstName
lastName
}
}
pageInfo {
......@@ -70,7 +71,9 @@ def test_first_after(client, snapshot):
edges {
cursor
node {
openidUid
id
firstName
lastName
}
}
pageInfo {
......@@ -94,7 +97,9 @@ def test_last(client, snapshot):
edges {
cursor
node {
openidUid
id
firstName
lastName
}
}
pageInfo {
......@@ -118,7 +123,9 @@ def test_last_before(client, snapshot):
edges {
cursor
node {
openidUid
id
firstName
lastName
}
}
pageInfo {
......
......@@ -41,7 +41,6 @@ def test_author(client, snapshot):
id
firstName
lastName
openidUid
extra
}}
}}
......@@ -95,7 +94,7 @@ def test_report(client, snapshot):
def test_user__unauthorized(client, snapshot):
User.objects.create(id=8, username='albert', openid_uid='albert@einstein.id',
first_name='Albert', last_name='Einstein')
first_name='Albert', last_name='Einstein', extra={'e': 'mc2'})
res = client.post('/graphql', {'query': """
query {{
node (id:"{id}") {{
......@@ -104,6 +103,8 @@ def test_user__unauthorized(client, snapshot):
firstName
lastName
openidUid
isAuthor
extra
}}
}}
}}
......@@ -113,9 +114,9 @@ def test_user__unauthorized(client, snapshot):
def test_user__not_a_viewer(client, snapshot):
User.objects.create(id=8, username='albert', openid_uid='albert@einstein.id',
first_name='Albert', last_name='Einstein')
first_name='Albert', last_name='Einstein', extra={'e': 'mc2'})
User.objects.create(id=2, username='isaac', openid_uid='isaac@newton.id',
first_name='Isaac', last_name='Newton')
first_name='Isaac', last_name='Newton', extra={'apple': 'hit'})
auth_header = 'Bearer {}'.format(create_access_token('isaac'))
res = client.post('/graphql', {'query': """
query {{
......@@ -125,6 +126,8 @@ def test_user__not_a_viewer(client, snapshot):
firstName
lastName
openidUid
isAuthor
extra
}}
}}
}}
......@@ -134,7 +137,7 @@ def test_user__not_a_viewer(client, snapshot):
def test_user(client, snapshot):
User.objects.create(id=8, username='albert', openid_uid='albert@einstein.id',
first_name='Albert', last_name='Einstein')
first_name='Albert', last_name='Einstein', extra={'e': 'mc2'})
auth_header = 'Bearer {}'.format(create_access_token('albert'))
res = client.post('/graphql', {'query': """
query {{
......@@ -144,6 +147,8 @@ def test_user(client, snapshot):
firstName
lastName
openidUid
isAuthor
extra
}}
}}
}}
......
......@@ -10,7 +10,8 @@ pytestmark = pytest.mark.django_db
@pytest.fixture(autouse=True)
def setup():
User.objects.create(id=1, is_author=True, username='wolfe', openid_uid='TheWolf',
first_name='Winston', last_name='Wolfe', email='winston@wolfe.com')
first_name='Winston', last_name='Wolfe', email='winston@wolfe.com',
extra={'caliber': 45})
def test_unauthenticated(client, snapshot):
......@@ -35,6 +36,8 @@ def test_authenticated(client, snapshot):
lastName
email
openidUid
isAuthor
extra
}
}
"""}, HTTP_AUTHORIZATION=auth_header)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment