Skip to content

Commit 9fb4703

Browse files
committed
test_extend_schema: improve test coverage
Replicates graphql/graphql-js@21fecc3
1 parent 4d0b0ae commit 9fb4703

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

tests/utilities/test_extend_schema.py

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -863,12 +863,15 @@ def extends_different_types_multiple_times():
863863
schema = build_schema(
864864
"""
865865
type Query {
866+
someScalar: SomeScalar
866867
someObject(someInput: SomeInput): SomeObject
867868
someInterface: SomeInterface
868869
someEnum: SomeEnum
869870
someUnion: SomeUnion
870871
}
871872
873+
scalar SomeScalar
874+
872875
type SomeObject implements SomeInterface {
873876
oldField: String
874877
}
@@ -888,9 +891,14 @@ def extends_different_types_multiple_times():
888891
}
889892
"""
890893
)
891-
new_types_sdl = """
892-
interface AnotherNewInterface {
893-
anotherNewField: String
894+
new_types_sdl = dedent(
895+
"""
896+
scalar NewScalar
897+
898+
scalar AnotherNewScalar
899+
900+
type NewObject {
901+
foo: String
894902
}
895903
896904
type AnotherNewObject {
@@ -901,13 +909,18 @@ def extends_different_types_multiple_times():
901909
newField: String
902910
}
903911
904-
type NewObject {
905-
foo: String
912+
interface AnotherNewInterface {
913+
anotherNewField: String
906914
}
907915
"""
916+
)
917+
schema_with_new_types = extend_schema(schema, parse(new_types_sdl))
918+
assert print_schema_changes(schema, schema_with_new_types) == new_types_sdl
919+
908920
extend_ast = parse(
909-
new_types_sdl
910-
+ """
921+
"""
922+
extend scalar SomeScalar @specifiedBy(url: "http://example.com/foo_spec")
923+
911924
extend type SomeObject implements NewInterface {
912925
newField: String
913926
}
@@ -937,11 +950,15 @@ def extends_different_types_multiple_times():
937950
}
938951
"""
939952
)
940-
extended_schema = extend_schema(schema, extend_ast)
953+
extended_schema = extend_schema(schema_with_new_types, extend_ast)
941954

942955
assert validate_schema(extended_schema) == []
943-
assert print_schema_changes(schema, extended_schema) == dedent(
944-
"""
956+
assert (
957+
print_schema_changes(schema, extended_schema)
958+
== dedent(
959+
"""
960+
scalar SomeScalar @specifiedBy(url: "http://example.com/foo_spec")
961+
945962
type SomeObject implements SomeInterface & NewInterface & AnotherNewInterface {
946963
oldField: String
947964
newField: String
@@ -960,7 +977,10 @@ def extends_different_types_multiple_times():
960977
oldField: String
961978
newField: String
962979
anotherNewField: String
963-
}\n""" # noqa: E501
980+
}
981+
982+
""" # noqa: E501
983+
)
964984
+ new_types_sdl
965985
)
966986

0 commit comments

Comments
 (0)