Skip to content

Commit c7dea56

Browse files
committed
Upgrade tests based on schema printing
graphql-core 3 prints the descriptions, and skips `schema` if it's the default one (query: Query)
1 parent c2ae343 commit c7dea56

File tree

2 files changed

+78
-18
lines changed

2 files changed

+78
-18
lines changed

graphene_django/filter/tests/test_fields.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -783,38 +783,55 @@ class Query(ObjectType):
783783

784784
assert str(schema) == dedent(
785785
"""\
786-
schema {
787-
query: Query
788-
}
789-
786+
\"""An object with an ID\"""
790787
interface Node {
788+
\"""The ID of the object\"""
791789
id: ID!
792790
}
793791
792+
\"""
793+
The Relay compliant `PageInfo` type, containing data necessary to paginate this connection.
794+
\"""
794795
type PageInfo {
796+
\"""When paginating forwards, are there more items?\"""
795797
hasNextPage: Boolean!
798+
799+
\"""When paginating backwards, are there more items?\"""
796800
hasPreviousPage: Boolean!
801+
802+
\"""When paginating backwards, the cursor to continue.\"""
797803
startCursor: String
804+
805+
\"""When paginating forwards, the cursor to continue.\"""
798806
endCursor: String
799807
}
800808
801809
type PetType implements Node {
802810
age: Int!
811+
812+
\"""The ID of the object\"""
803813
id: ID!
804814
}
805815
806816
type PetTypeConnection {
817+
\"""Pagination data for this connection.\"""
807818
pageInfo: PageInfo!
819+
820+
\"""Contains the nodes in this connection.\"""
808821
edges: [PetTypeEdge]!
809822
}
810823
824+
\"""A Relay edge containing a `PetType` and its cursor.\"""
811825
type PetTypeEdge {
826+
\"""The item at the end of the edge\"""
812827
node: PetType
828+
829+
\"""A cursor for use in pagination\"""
813830
cursor: String!
814831
}
815832
816833
type Query {
817-
pets(before: String, after: String, first: Int, last: Int, age: Int): PetTypeConnection
834+
pets(before: String = null, after: String = null, first: Int = null, last: Int = null, age: Int = null): PetTypeConnection
818835
}
819836
"""
820837
)

graphene_django/tests/test_types.py

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -118,53 +118,95 @@ def test_schema_representation():
118118
query: RootQuery
119119
}
120120
121+
\"""Article description\"""
121122
type Article implements Node {
123+
\"""The ID of the object\"""
122124
id: ID!
123125
headline: String!
124126
pubDate: Date!
125127
pubDateTime: DateTime!
126128
reporter: Reporter!
127129
editor: Reporter!
130+
131+
\"""Language\"""
128132
lang: ArticleLang!
129133
importance: ArticleImportance
130134
}
131135
132136
type ArticleConnection {
137+
\"""Pagination data for this connection.\"""
133138
pageInfo: PageInfo!
139+
140+
\"""Contains the nodes in this connection.\"""
134141
edges: [ArticleEdge]!
135142
test: String
136143
}
137144
145+
\"""A Relay edge containing a `Article` and its cursor.\"""
138146
type ArticleEdge {
147+
\"""The item at the end of the edge\"""
139148
node: Article
149+
150+
\"""A cursor for use in pagination\"""
140151
cursor: String!
141152
}
142153
154+
\"""An enumeration.\"""
143155
enum ArticleImportance {
156+
\"""Very important\"""
144157
A_1
158+
159+
\"""Not as important\"""
145160
A_2
146161
}
147162
163+
\"""An enumeration.\"""
148164
enum ArticleLang {
165+
\"""Spanish\"""
149166
ES
167+
168+
\"""English\"""
150169
EN
151170
}
152171
172+
\"""
173+
The `Date` scalar type represents a Date
174+
value as specified by
175+
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
176+
\"""
153177
scalar Date
154178
179+
\"""
180+
The `DateTime` scalar type represents a DateTime
181+
value as specified by
182+
[iso8601](https://en.wikipedia.org/wiki/ISO_8601).
183+
\"""
155184
scalar DateTime
156185
186+
\"""An object with an ID\"""
157187
interface Node {
188+
\"""The ID of the object\"""
158189
id: ID!
159190
}
160191
192+
\"""
193+
The Relay compliant `PageInfo` type, containing data necessary to paginate this connection.
194+
\"""
161195
type PageInfo {
196+
\"""When paginating forwards, are there more items?\"""
162197
hasNextPage: Boolean!
198+
199+
\"""When paginating backwards, are there more items?\"""
163200
hasPreviousPage: Boolean!
201+
202+
\"""When paginating backwards, the cursor to continue.\"""
164203
startCursor: String
204+
205+
\"""When paginating forwards, the cursor to continue.\"""
165206
endCursor: String
166207
}
167208
209+
\"""Reporter description\"""
168210
type Reporter {
169211
id: ID!
170212
firstName: String!
@@ -173,20 +215,29 @@ def test_schema_representation():
173215
pets: [Reporter!]!
174216
aChoice: ReporterAChoice
175217
reporterType: ReporterReporterType
176-
articles(before: String, after: String, first: Int, last: Int): ArticleConnection!
218+
articles(before: String = null, after: String = null, first: Int = null, last: Int = null): ArticleConnection!
177219
}
178220
221+
\"""An enumeration.\"""
179222
enum ReporterAChoice {
223+
\"""this\"""
180224
A_1
225+
226+
\"""that\"""
181227
A_2
182228
}
183229
230+
\"""An enumeration.\"""
184231
enum ReporterReporterType {
232+
\"""Regular\"""
185233
A_1
234+
235+
\"""CNN Reporter\"""
186236
A_2
187237
}
188238
189239
type RootQuery {
240+
\"""The ID of the object\"""
190241
node(id: ID!): Node
191242
}
192243
""".lstrip()
@@ -346,10 +397,6 @@ class Query(ObjectType):
346397

347398
assert str(schema) == dedent(
348399
"""\
349-
schema {
350-
query: Query
351-
}
352-
353400
type Pet {
354401
id: ID!
355402
kind: String!
@@ -375,18 +422,18 @@ class Query(ObjectType):
375422

376423
assert str(schema) == dedent(
377424
"""\
378-
schema {
379-
query: Query
380-
}
381-
382425
type Pet {
383426
id: ID!
384427
kind: PetModelKind!
385428
cuteness: Int!
386429
}
387430
431+
\"""An enumeration.\"""
388432
enum PetModelKind {
433+
\"""Cat\"""
389434
CAT
435+
436+
\"""Dog\"""
390437
DOG
391438
}
392439
@@ -409,10 +456,6 @@ class Query(ObjectType):
409456

410457
assert str(schema) == dedent(
411458
"""\
412-
schema {
413-
query: Query
414-
}
415-
416459
type Pet {
417460
id: ID!
418461
kind: String!

0 commit comments

Comments
 (0)