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 = [
'openid_uid': 'Wolf',
'first_name': 'Winston',
'last_name': 'Wolfe',
'is_author': True,
'extra': {'movies': 1},
},
{
'id': 2,
......@@ -17,6 +19,15 @@ authors = [
'openid_uid': 'sponge',
'first_name': 'Spongebob',
'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():
def prepare_report():
author = User.objects.create(**authors[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'] = {
{
'cursor': 'MQ==',
'node': {
'extra': '{"x": 1}',
'extra': '{"movies": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe',
'openidUid': 'first'
'openidUid': 'Wolf'
}
},
{
'cursor': 'Mg==',
'node': {
'extra': None,
'firstName': 'Captain',
'id': 'QXV0aG9yOjM=',
'lastName': 'Obvious',
'openidUid': 'second'
'firstName': 'Spongebob',
'id': 'QXV0aG9yOjI=',
'lastName': 'Squarepants',
'openidUid': 'sponge'
}
},
{
......@@ -36,9 +36,9 @@ snapshots['test_all 1'] = {
'node': {
'extra': None,
'firstName': 'Shaun',
'id': 'QXV0aG9yOjQ=',
'id': 'QXV0aG9yOjM=',
'lastName': 'Sheep',
'openidUid': 'third'
'openidUid': 'shaun'
}
}
],
......@@ -60,13 +60,13 @@ snapshots['test_first 1'] = {
{
'cursor': 'MQ==',
'node': {
'openidUid': 'first'
'openidUid': 'Wolf'
}
},
{
'cursor': 'Mg==',
'node': {
'openidUid': 'second'
'openidUid': 'sponge'
}
}
],
......@@ -88,7 +88,7 @@ snapshots['test_first_after 1'] = {
{
'cursor': 'Mg==',
'node': {
'openidUid': 'second'
'openidUid': 'sponge'
}
}
],
......@@ -127,7 +127,7 @@ snapshots['test_last_before 1'] = {
{
'cursor': 'Mg==',
'node': {
'openidUid': 'second'
'openidUid': 'sponge'
}
}
],
......
......@@ -38,7 +38,7 @@ snapshots['test_report 1'] = {
'data': {
'node': {
'author': {
'extra': None,
'extra': '{"movies": 1}',
'firstName': 'Winston',
'id': 'QXV0aG9yOjE=',
'lastName': 'Wolfe'
......
......@@ -2,23 +2,15 @@ import pytest
from openlobby.core.models import User
from ..dummy import prepare_authors
pytestmark = pytest.mark.django_db
@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
pytestmark = [pytest.mark.django_db, pytest.mark.usefixtures('django_es')]
def test_all(client, snapshot):
prepare_authors()
User.objects.create(id=4, is_author=False, username='x')
res = client.post('/graphql', {'query': """
query {
authors {
......@@ -46,6 +38,7 @@ def test_all(client, snapshot):
def test_first(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """
query {
authors (first: 2) {
......@@ -69,6 +62,7 @@ def test_first(client, snapshot):
def test_first_after(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """
query {
authors (first: 1, after: "MQ==") {
......@@ -92,6 +86,7 @@ def test_first_after(client, snapshot):
def test_last(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """
query {
authors (last: 2) {
......@@ -115,6 +110,7 @@ def test_last(client, snapshot):
def test_last_before(client, snapshot):
prepare_authors()
res = client.post('/graphql', {'query': """
query {
authors (last: 1, before: "Mw==") {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment