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

Tests dummy data - prepare authors.

parent 2e7baa5b
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,8 @@ authors = [ ...@@ -10,6 +10,8 @@ authors = [
'openid_uid': 'Wolf', 'openid_uid': 'Wolf',
'first_name': 'Winston', 'first_name': 'Winston',
'last_name': 'Wolfe', 'last_name': 'Wolfe',
'is_author': True,
'extra': {'movies': 1},
}, },
{ {
'id': 2, 'id': 2,
...@@ -17,6 +19,15 @@ authors = [ ...@@ -17,6 +19,15 @@ authors = [
'openid_uid': 'sponge', 'openid_uid': 'sponge',
'first_name': 'Spongebob', 'first_name': 'Spongebob',
'last_name': 'Squarepants', 'last_name': 'Squarepants',
'is_author': True,
},
{
'id': 3,
'username': 'shaun',
'openid_uid': 'shaun',
'first_name': 'Shaun',
'last_name': 'Sheep',
'is_author': True,
}, },
] ]
...@@ -69,3 +80,8 @@ def prepare_reports(): ...@@ -69,3 +80,8 @@ def prepare_reports():
def prepare_report(): def prepare_report():
author = User.objects.create(**authors[0]) author = User.objects.create(**authors[0])
Report.objects.create(author=author, **reports[0]) Report.objects.create(author=author, **reports[0])
def prepare_authors():
for author in authors:
User.objects.create(**author)
...@@ -14,21 +14,21 @@ snapshots['test_all 1'] = { ...@@ -14,21 +14,21 @@ snapshots['test_all 1'] = {
{ {
'cursor': 'MQ==', 'cursor': 'MQ==',
'node': { 'node': {
'extra': '{"x": 1}', 'extra': '{"movies": 1}',
'firstName': 'Winston', 'firstName': 'Winston',
'id': 'QXV0aG9yOjE=', 'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe', 'lastName': 'Wolfe',
'openidUid': 'first' 'openidUid': 'Wolf'
} }
}, },
{ {
'cursor': 'Mg==', 'cursor': 'Mg==',
'node': { 'node': {
'extra': None, 'extra': None,
'firstName': 'Captain', 'firstName': 'Spongebob',
'id': 'QXV0aG9yOjM=', 'id': 'QXV0aG9yOjI=',
'lastName': 'Obvious', 'lastName': 'Squarepants',
'openidUid': 'second' 'openidUid': 'sponge'
} }
}, },
{ {
...@@ -36,9 +36,9 @@ snapshots['test_all 1'] = { ...@@ -36,9 +36,9 @@ snapshots['test_all 1'] = {
'node': { 'node': {
'extra': None, 'extra': None,
'firstName': 'Shaun', 'firstName': 'Shaun',
'id': 'QXV0aG9yOjQ=', 'id': 'QXV0aG9yOjM=',
'lastName': 'Sheep', 'lastName': 'Sheep',
'openidUid': 'third' 'openidUid': 'shaun'
} }
} }
], ],
...@@ -60,13 +60,13 @@ snapshots['test_first 1'] = { ...@@ -60,13 +60,13 @@ snapshots['test_first 1'] = {
{ {
'cursor': 'MQ==', 'cursor': 'MQ==',
'node': { 'node': {
'openidUid': 'first' 'openidUid': 'Wolf'
} }
}, },
{ {
'cursor': 'Mg==', 'cursor': 'Mg==',
'node': { 'node': {
'openidUid': 'second' 'openidUid': 'sponge'
} }
} }
], ],
...@@ -88,7 +88,7 @@ snapshots['test_first_after 1'] = { ...@@ -88,7 +88,7 @@ snapshots['test_first_after 1'] = {
{ {
'cursor': 'Mg==', 'cursor': 'Mg==',
'node': { 'node': {
'openidUid': 'second' 'openidUid': 'sponge'
} }
} }
], ],
...@@ -127,7 +127,7 @@ snapshots['test_last_before 1'] = { ...@@ -127,7 +127,7 @@ snapshots['test_last_before 1'] = {
{ {
'cursor': 'Mg==', 'cursor': 'Mg==',
'node': { 'node': {
'openidUid': 'second' 'openidUid': 'sponge'
} }
} }
], ],
......
...@@ -38,7 +38,7 @@ snapshots['test_report 1'] = { ...@@ -38,7 +38,7 @@ snapshots['test_report 1'] = {
'data': { 'data': {
'node': { 'node': {
'author': { 'author': {
'extra': None, 'extra': '{"movies": 1}',
'firstName': 'Winston', 'firstName': 'Winston',
'id': 'QXV0aG9yOjE=', 'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe' 'lastName': 'Wolfe'
......
...@@ -2,23 +2,15 @@ import pytest ...@@ -2,23 +2,15 @@ import pytest
from openlobby.core.models import User from openlobby.core.models import User
from ..dummy import prepare_authors
pytestmark = pytest.mark.django_db
pytestmark = [pytest.mark.django_db, pytest.mark.usefixtures('django_es')]
@pytest.fixture(autouse=True)
def setup():
User.objects.create(id=1, is_author=True, username='a', openid_uid='first',
first_name='Winston', last_name='Wolfe', extra={'x': 1})
User.objects.create(id=2, is_author=False, username='b')
User.objects.create(id=3, is_author=True, username='c', openid_uid='second',
first_name='Captain', last_name='Obvious')
User.objects.create(id=4, is_author=True, username='d', openid_uid='third',
first_name='Shaun', last_name='Sheep')
yield
def test_all(client, snapshot): def test_all(client, snapshot):
prepare_authors()
User.objects.create(id=4, is_author=False, username='x')
res = client.post('/graphql', {'query': """ res = client.post('/graphql', {'query': """
query { query {
authors { authors {
...@@ -46,6 +38,7 @@ def test_all(client, snapshot): ...@@ -46,6 +38,7 @@ def test_all(client, snapshot):
def test_first(client, snapshot): def test_first(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """ res = client.post('/graphql', {'query': """
query { query {
authors (first: 2) { authors (first: 2) {
...@@ -69,6 +62,7 @@ def test_first(client, snapshot): ...@@ -69,6 +62,7 @@ def test_first(client, snapshot):
def test_first_after(client, snapshot): def test_first_after(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """ res = client.post('/graphql', {'query': """
query { query {
authors (first: 1, after: "MQ==") { authors (first: 1, after: "MQ==") {
...@@ -92,6 +86,7 @@ def test_first_after(client, snapshot): ...@@ -92,6 +86,7 @@ def test_first_after(client, snapshot):
def test_last(client, snapshot): def test_last(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """ res = client.post('/graphql', {'query': """
query { query {
authors (last: 2) { authors (last: 2) {
...@@ -115,6 +110,7 @@ def test_last(client, snapshot): ...@@ -115,6 +110,7 @@ def test_last(client, snapshot):
def test_last_before(client, snapshot): def test_last_before(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """ res = client.post('/graphql', {'query': """
query { query {
authors (last: 1, before: "Mw==") { authors (last: 1, before: "Mw==") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment