Skip to content

Commit 97a6f7b

Browse files
committed
Start using pytest-describe
This allows using the same test structure and names as in the original and makes tests a bit more organized.
1 parent bab02d5 commit 97a6f7b

File tree

9 files changed

+462
-449
lines changed

9 files changed

+462
-449
lines changed

poetry.lock

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ graphql-core-next = "^1.0.5"
3434
pytest = "^5"
3535
pytest-asyncio = ">=0.10"
3636
pytest-cov = "^2.7"
37+
pytest-describe = ">=0.12"
3738
pyyaml = "^5.1"
3839
black = ">=19.3b0"
3940
flake8 = "^3.7"

src/graphql_relay/utils/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33

44
def resolve_maybe_thunk(f): # TODO: do we need that?
55
return f() if callable(f) else f
6-

tests/node/test_global.py

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
from typing import Any, NamedTuple, Union
22

3-
from pytest import mark
4-
53
from graphql import graphql_sync as graphql
64
from graphql.type import (
75
GraphQLField,
@@ -119,78 +117,79 @@ def get_node_type(
119117
)
120118

121119

122-
def test_gives_different_ids():
123-
query = '''
124-
{
125-
allObjects {
126-
id
127-
}
128-
}
129-
'''
130-
assert graphql(schema, query) == (
120+
def describe_global_id_fields():
121+
122+
def gives_different_ids():
123+
query = '''
131124
{
132-
'allObjects': [
133-
{
134-
'id': 'VXNlcjox'
135-
},
136-
{
137-
'id': 'VXNlcjoy'
138-
},
139-
{
140-
'id': 'UGhvdG86MQ=='
125+
allObjects {
126+
id
127+
}
128+
}
129+
'''
130+
assert graphql(schema, query) == (
131+
{
132+
'allObjects': [
133+
{
134+
'id': 'VXNlcjox'
135+
},
136+
{
137+
'id': 'VXNlcjoy'
138+
},
139+
{
140+
'id': 'UGhvdG86MQ=='
141+
},
142+
{
143+
'id': 'UGhvdG86Mg=='
144+
},
145+
{
146+
'id': 'UG9zdDox',
147+
},
148+
{
149+
'id': 'UG9zdDoy',
150+
},
151+
]
152+
},
153+
None
154+
)
155+
156+
def refetches_the_ids():
157+
query = '''
158+
{
159+
user: node(id: "VXNlcjox") {
160+
id
161+
... on User {
162+
name
163+
}
164+
},
165+
photo: node(id: "UGhvdG86MQ==") {
166+
id
167+
... on Photo {
168+
width
169+
}
170+
}
171+
post: node(id: "UG9zdDox") {
172+
id
173+
... on Post {
174+
text
175+
}
176+
}
177+
}
178+
'''
179+
assert graphql(schema, query) == (
180+
{
181+
'user': {
182+
'id': 'VXNlcjox',
183+
'name': 'John Doe'
141184
},
142-
{
143-
'id': 'UGhvdG86Mg=='
185+
'photo': {
186+
'id': 'UGhvdG86MQ==',
187+
'width': 300
144188
},
145-
{
189+
'post': {
146190
'id': 'UG9zdDox',
191+
'text': 'lorem',
147192
},
148-
{
149-
'id': 'UG9zdDoy',
150-
},
151-
]
152-
},
153-
None
154-
)
155-
156-
157-
def test_refetches_the_ids():
158-
query = '''
159-
{
160-
user: node(id: "VXNlcjox") {
161-
id
162-
... on User {
163-
name
164-
}
165-
},
166-
photo: node(id: "UGhvdG86MQ==") {
167-
id
168-
... on Photo {
169-
width
170-
}
171-
}
172-
post: node(id: "UG9zdDox") {
173-
id
174-
... on Post {
175-
text
176-
}
177-
}
178-
}
179-
'''
180-
assert graphql(schema, query) == (
181-
{
182-
'user': {
183-
'id': 'VXNlcjox',
184-
'name': 'John Doe'
185-
},
186-
'photo': {
187-
'id': 'UGhvdG86MQ==',
188-
'width': 300
189193
},
190-
'post': {
191-
'id': 'UG9zdDox',
192-
'text': 'lorem',
193-
},
194-
},
195-
None
196-
)
194+
None
195+
)

0 commit comments

Comments
 (0)