Skip to content

Commit ff5164a

Browse files
committed
introspection-test: simplify tests for description fields
Replicates graphql/graphql-js@b14de03
1 parent ab1e694 commit ff5164a

File tree

1 file changed

+39
-108
lines changed

1 file changed

+39
-108
lines changed

tests/type/test_introspection.py

Lines changed: 39 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1253,85 +1253,42 @@ def fails_as_expected_on_the_type_root_field_without_an_arg():
12531253
],
12541254
)
12551255

1256-
def exposes_descriptions_on_types_and_fields():
1256+
def exposes_descriptions():
12571257
schema = build_schema(
1258-
"""
1259-
type Query {
1260-
someField: String
1258+
'''
1259+
"""Enum description"""
1260+
enum SomeEnum {
1261+
"""Value description"""
1262+
VALUE
12611263
}
1262-
"""
1263-
)
12641264
1265-
source = """
1266-
{
1267-
schemaType: __type(name: "__Schema") {
1268-
name,
1269-
description,
1270-
fields {
1271-
name,
1272-
description
1273-
}
1274-
}
1265+
"""Object description"""
1266+
type SomeObject {
1267+
"""Field description"""
1268+
someField(arg: SomeEnum): String
12751269
}
1276-
"""
1277-
1278-
assert graphql_sync(schema=schema, source=source) == (
1279-
{
1280-
"schemaType": {
1281-
"name": "__Schema",
1282-
"description": "A GraphQL Schema defines the capabilities of a"
1283-
" GraphQL server. It exposes all available types and"
1284-
" directives on the server, as well as the entry points"
1285-
" for query, mutation, and subscription operations.",
1286-
"fields": [
1287-
{"name": "description", "description": None},
1288-
{
1289-
"name": "types",
1290-
"description": "A list of all types supported"
1291-
" by this server.",
1292-
},
1293-
{
1294-
"name": "queryType",
1295-
"description": "The type that query operations"
1296-
" will be rooted at.",
1297-
},
1298-
{
1299-
"name": "mutationType",
1300-
"description": "If this server supports mutation, the type"
1301-
" that mutation operations will be rooted at.",
1302-
},
1303-
{
1304-
"name": "subscriptionType",
1305-
"description": "If this server support subscription,"
1306-
" the type that subscription operations will be rooted at.",
1307-
},
1308-
{
1309-
"name": "directives",
1310-
"description": "A list of all directives supported"
1311-
" by this server.",
1312-
},
1313-
],
1314-
}
1315-
},
1316-
None,
1317-
)
13181270
1319-
def exposes_descriptions_on_enums():
1320-
schema = build_schema(
1321-
"""
1322-
type Query {
1323-
someField: String
1271+
"""Schema description"""
1272+
schema {
1273+
query: SomeObject
13241274
}
1325-
"""
1275+
'''
13261276
)
13271277

13281278
source = """
13291279
{
1330-
typeKindType: __type(name: "__TypeKind") {
1331-
name,
1280+
Schema: __schema { description }
1281+
SomeObject: __type(name: "SomeObject") {
13321282
description,
1283+
fields {
1284+
name
1285+
description
1286+
}
1287+
}
1288+
SomeEnum: __type(name: "SomeEnum") {
1289+
description
13331290
enumValues {
1334-
name,
1291+
name
13351292
description
13361293
}
13371294
}
@@ -1340,53 +1297,27 @@ def exposes_descriptions_on_enums():
13401297

13411298
assert graphql_sync(schema=schema, source=source) == (
13421299
{
1343-
"typeKindType": {
1344-
"name": "__TypeKind",
1345-
"description": "An enum describing what kind of type"
1346-
" a given `__Type` is.",
1300+
"Schema": {
1301+
"description": "Schema description",
1302+
},
1303+
"SomeEnum": {
1304+
"description": "Enum description",
13471305
"enumValues": [
13481306
{
1349-
"name": "SCALAR",
1350-
"description": "Indicates this type is a scalar.",
1351-
},
1352-
{
1353-
"name": "OBJECT",
1354-
"description": "Indicates this type is an object."
1355-
+ " `fields` and `interfaces` are valid fields.",
1356-
},
1357-
{
1358-
"name": "INTERFACE",
1359-
"description": "Indicates this type is an interface."
1360-
" `fields`, `interfaces`, and `possibleTypes`"
1361-
" are valid fields.",
1362-
},
1363-
{
1364-
"name": "UNION",
1365-
"description": "Indicates this type is a union."
1366-
" `possibleTypes` is a valid field.",
1367-
},
1368-
{
1369-
"name": "ENUM",
1370-
"description": "Indicates this type is an enum."
1371-
" `enumValues` is a valid field.",
1372-
},
1373-
{
1374-
"name": "INPUT_OBJECT",
1375-
"description": "Indicates this type is an input object."
1376-
" `inputFields` is a valid field.",
1377-
},
1378-
{
1379-
"name": "LIST",
1380-
"description": "Indicates this type is a list."
1381-
" `ofType` is a valid field.",
1307+
"name": "VALUE",
1308+
"description": "Value description",
13821309
},
1310+
],
1311+
},
1312+
"SomeObject": {
1313+
"description": "Object description",
1314+
"fields": [
13831315
{
1384-
"name": "NON_NULL",
1385-
"description": "Indicates this type is a non-null."
1386-
" `ofType` is a valid field.",
1316+
"name": "someField",
1317+
"description": "Field description",
13871318
},
13881319
],
1389-
}
1320+
},
13901321
},
13911322
None,
13921323
)

0 commit comments

Comments
 (0)