Skip to content

Commit 323fc2b

Browse files
committed
test_single_field_subscriptions: extract test schema from harness
Replicates graphql/graphql-js@d82c8e2
1 parent 77838b4 commit 323fc2b

File tree

2 files changed

+39
-30
lines changed

2 files changed

+39
-30
lines changed

tests/validation/harness.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
__all__ = [
1111
"test_schema",
12-
"empty_schema",
1312
"assert_validation_errors",
1413
"assert_sdl_validation_errors",
1514
]
@@ -134,23 +133,8 @@
134133
complicatedArgs: ComplicatedArgs
135134
}
136135
137-
type Message {
138-
body: String
139-
sender: String
140-
}
141-
142-
type SubscriptionRoot {
143-
importantEmails: [String]
144-
notImportantEmails: [String]
145-
moreImportantEmails: [String]
146-
spamEmails: [String]
147-
deletedEmails: [String]
148-
newMessage: Message
149-
}
150-
151136
schema {
152137
query: QueryRoot
153-
subscription: SubscriptionRoot
154138
}
155139
156140
directive @onQuery on QUERY
@@ -164,18 +148,6 @@
164148
"""
165149
)
166150

167-
empty_schema = build_schema(
168-
"""
169-
type QueryRoot {
170-
empty: Boolean
171-
}
172-
173-
schema {
174-
query: QueryRoot
175-
}
176-
"""
177-
)
178-
179151

180152
def assert_validation_errors(
181153
rule: Type[ValidationRule],

tests/validation/test_single_field_subscriptions.py

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,40 @@
11
from functools import partial
22

3+
from graphql.utilities import build_schema
34
from graphql.validation import SingleFieldSubscriptionsRule
45

5-
from .harness import assert_validation_errors, empty_schema
6+
from .harness import assert_validation_errors
67

7-
assert_errors = partial(assert_validation_errors, SingleFieldSubscriptionsRule)
8+
schema = build_schema(
9+
"""
10+
type Message {
11+
body: String
12+
sender: String
13+
}
14+
15+
type SubscriptionRoot {
16+
importantEmails: [String]
17+
notImportantEmails: [String]
18+
moreImportantEmails: [String]
19+
spamEmails: [String]
20+
deletedEmails: [String]
21+
newMessage: Message
22+
}
23+
24+
type QueryRoot {
25+
dummy: String
26+
}
27+
28+
schema {
29+
query: QueryRoot
30+
subscription: SubscriptionRoot
31+
}
32+
"""
33+
)
34+
35+
assert_errors = partial(
36+
assert_validation_errors, SingleFieldSubscriptionsRule, schema=schema
37+
)
838

939
assert_valid = partial(assert_errors, errors=[])
1040

@@ -262,6 +292,13 @@ def fails_with_introspection_field_in_anonymous_subscription():
262292
)
263293

264294
def skips_if_not_subscription_type():
295+
empty_schema = build_schema(
296+
"""
297+
type Query {
298+
dummy: String
299+
}
300+
"""
301+
)
265302
assert_errors(
266303
"""
267304
subscription {

0 commit comments

Comments
 (0)