Skip to content

Commit eef87fc

Browse files
committed
test_build_client_schema: remove dependency on order of types
1 parent ad1b7c7 commit eef87fc

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

.coveragerc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exclude_lines =
1111
raise NotImplementedError
1212
raise TypeError\(f?"Unexpected
1313
assert False,
14+
\s+next\($
1415
if MYPY:
1516
if TYPE_CHECKING:
1617
^\s+\.\.\.$

tests/utilities/test_build_client_schema.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ def throws_when_type_reference_is_missing_name():
669669
def throws_when_missing_kind():
670670
introspection = introspection_from_schema(dummy_schema)
671671

672-
query_type_introspection = next( # pragma: no cover
672+
query_type_introspection = next(
673673
type_
674674
for type_ in introspection["__schema"]["types"]
675675
if type_["name"] == "Query"
@@ -688,7 +688,7 @@ def throws_when_missing_kind():
688688
def throws_when_missing_interfaces():
689689
introspection = introspection_from_schema(dummy_schema)
690690

691-
query_type_introspection = next( # pragma: no cover
691+
query_type_introspection = next(
692692
type_
693693
for type_ in introspection["__schema"]["types"]
694694
if type_["name"] == "Query"
@@ -706,7 +706,7 @@ def throws_when_missing_interfaces():
706706

707707
def legacy_support_for_interfaces_with_null_as_interfaces_field():
708708
introspection = introspection_from_schema(dummy_schema)
709-
some_interface_introspection = next( # pragma: no cover
709+
some_interface_introspection = next(
710710
type_
711711
for type_ in introspection["__schema"]["types"]
712712
if type_["name"] == "SomeInterface"
@@ -720,7 +720,7 @@ def legacy_support_for_interfaces_with_null_as_interfaces_field():
720720

721721
def throws_when_missing_fields():
722722
introspection = introspection_from_schema(dummy_schema)
723-
query_type_introspection = next( # pragma: no cover
723+
query_type_introspection = next(
724724
type_
725725
for type_ in introspection["__schema"]["types"]
726726
if type_["name"] == "Query"
@@ -740,7 +740,7 @@ def throws_when_missing_fields():
740740
def throws_when_missing_field_args():
741741
introspection = introspection_from_schema(dummy_schema)
742742

743-
query_type_introspection = next( # pragma: no cover
743+
query_type_introspection = next(
744744
type_
745745
for type_ in introspection["__schema"]["types"]
746746
if type_["name"] == "Query"
@@ -758,7 +758,7 @@ def throws_when_missing_field_args():
758758
def throws_when_output_type_is_used_as_an_arg_type():
759759
introspection = introspection_from_schema(dummy_schema)
760760

761-
query_type_introspection = next( # pragma: no cover
761+
query_type_introspection = next(
762762
type_
763763
for type_ in introspection["__schema"]["types"]
764764
if type_["name"] == "Query"
@@ -783,7 +783,7 @@ def throws_when_output_type_is_used_as_an_arg_type():
783783
def throws_when_output_type_is_used_as_an_input_value_type():
784784
introspection = introspection_from_schema(dummy_schema)
785785

786-
input_object_type_introspection = next( # pragma: no cover
786+
input_object_type_introspection = next(
787787
type_
788788
for type_ in introspection["__schema"]["types"]
789789
if type_["name"] == "SomeInputObject"
@@ -808,7 +808,7 @@ def throws_when_output_type_is_used_as_an_input_value_type():
808808
def throws_when_input_type_is_used_as_a_field_type():
809809
introspection = introspection_from_schema(dummy_schema)
810810

811-
query_type_introspection = next( # pragma: no cover
811+
query_type_introspection = next(
812812
type_
813813
for type_ in introspection["__schema"]["types"]
814814
if type_["name"] == "Query"
@@ -828,7 +828,7 @@ def throws_when_input_type_is_used_as_a_field_type():
828828
def throws_when_missing_possible_types():
829829
introspection = introspection_from_schema(dummy_schema)
830830

831-
some_union_introspection = next( # pragma: no cover
831+
some_union_introspection = next(
832832
type_
833833
for type_ in introspection["__schema"]["types"]
834834
if type_["name"] == "SomeUnion"
@@ -846,7 +846,7 @@ def throws_when_missing_possible_types():
846846
def throws_when_missing_enum_values():
847847
introspection = introspection_from_schema(dummy_schema)
848848

849-
some_enum_introspection = next( # pragma: no cover
849+
some_enum_introspection = next(
850850
type_
851851
for type_ in introspection["__schema"]["types"]
852852
if type_["name"] == "SomeEnum"
@@ -864,7 +864,7 @@ def throws_when_missing_enum_values():
864864
def throws_when_missing_input_fields():
865865
introspection = introspection_from_schema(dummy_schema)
866866

867-
some_input_object_introspection = next( # pragma: no cover
867+
some_input_object_introspection = next(
868868
type_
869869
for type_ in introspection["__schema"]["types"]
870870
if type_["name"] == "SomeInputObject"
@@ -974,11 +974,14 @@ def recursive_interfaces():
974974
schema = build_schema(sdl, assume_valid=True)
975975
introspection = introspection_from_schema(schema)
976976

977-
foo_type_introspection = introspection["__schema"]["types"][1]
978-
assert foo_type_introspection["name"] == "Foo"
979-
assert foo_type_introspection["interfaces"] == []
977+
foo_introspection = next(
978+
type_
979+
for type_ in introspection["__schema"]["types"]
980+
if type_["name"] == "Foo"
981+
)
982+
assert foo_introspection["interfaces"] == []
980983
# we need to patch here since invalid interfaces cannot be built with Python
981-
foo_type_introspection["interfaces"] = [
984+
foo_introspection["interfaces"] = [
982985
{"kind": "OBJECT", "name": "Foo", "ofType": None}
983986
]
984987

@@ -1000,12 +1003,15 @@ def recursive_union():
10001003
schema = build_schema(sdl, assume_valid=True)
10011004
introspection = introspection_from_schema(schema)
10021005

1003-
foo_type_introspection = introspection["__schema"]["types"][1]
1004-
assert foo_type_introspection["name"] == "Foo"
1005-
assert foo_type_introspection["kind"] == "UNION"
1006-
assert foo_type_introspection["possibleTypes"] == []
1006+
foo_introspection = next(
1007+
type_
1008+
for type_ in introspection["__schema"]["types"]
1009+
if type_["name"] == "Foo"
1010+
)
1011+
assert foo_introspection["kind"] == "UNION"
1012+
assert foo_introspection["possibleTypes"] == []
10071013
# we need to patch here since invalid unions cannot be built with Python
1008-
foo_type_introspection["possibleTypes"] = [
1014+
foo_introspection["possibleTypes"] = [
10091015
{"kind": "UNION", "name": "Foo", "ofType": None}
10101016
]
10111017

0 commit comments

Comments
 (0)