Skip to content

Commit 056cb0f

Browse files
committed
Simplify test for find_breaking_changes
Replicates graphql/graphql-js@0addc5b
1 parent ae2ccea commit 056cb0f

File tree

1 file changed

+14
-42
lines changed

1 file changed

+14
-42
lines changed

tests/utilities/test_find_breaking_changes.py

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,9 @@ def should_detect_if_a_field_on_type_was_deleted_or_changed_type():
171171
"""
172172
)
173173

174-
expected_field_changes = [
174+
assert find_fields_that_changed_type_on_object_or_interface_types(
175+
old_schema, new_schema
176+
) == [
175177
(BreakingChangeType.FIELD_REMOVED, "Type1.field2 was removed."),
176178
(
177179
BreakingChangeType.FIELD_CHANGED_KIND,
@@ -223,13 +225,6 @@ def should_detect_if_a_field_on_type_was_deleted_or_changed_type():
223225
),
224226
]
225227

226-
assert (
227-
find_fields_that_changed_type_on_object_or_interface_types(
228-
old_schema, new_schema
229-
)
230-
== expected_field_changes
231-
)
232-
233228
def should_detect_if_fields_on_input_types_changed_kind_or_were_removed():
234229
old_schema = build_schema(
235230
"""
@@ -281,7 +276,9 @@ def should_detect_if_fields_on_input_types_changed_kind_or_were_removed():
281276
"""
282277
)
283278

284-
expected_field_changes = [
279+
assert find_fields_that_changed_type_on_input_object_types(
280+
old_schema, new_schema
281+
).breaking_changes == [
285282
(
286283
BreakingChangeType.FIELD_CHANGED_KIND,
287284
"InputType1.field1 changed type from String to Int.",
@@ -325,13 +322,6 @@ def should_detect_if_fields_on_input_types_changed_kind_or_were_removed():
325322
),
326323
]
327324

328-
assert (
329-
find_fields_that_changed_type_on_input_object_types(
330-
old_schema, new_schema
331-
).breaking_changes
332-
== expected_field_changes
333-
)
334-
335325
def should_detect_if_a_required_field_is_added_to_an_input_type():
336326
old_schema = build_schema(
337327
"""
@@ -360,20 +350,15 @@ def should_detect_if_a_required_field_is_added_to_an_input_type():
360350
"""
361351
)
362352

363-
expected_field_changes = [
353+
assert find_fields_that_changed_type_on_input_object_types(
354+
old_schema, new_schema
355+
).breaking_changes == [
364356
(
365357
BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED,
366358
"A required field requiredField on input type InputType1 was added.",
367359
)
368360
]
369361

370-
assert (
371-
find_fields_that_changed_type_on_input_object_types(
372-
old_schema, new_schema
373-
).breaking_changes
374-
== expected_field_changes
375-
)
376-
377362
def should_detect_if_a_type_was_removed_from_a_union_type():
378363
old_schema = build_schema(
379364
"""
@@ -846,7 +831,7 @@ def should_detect_all_breaking_changes():
846831
"""
847832
)
848833

849-
expected_breaking_changes = [
834+
assert find_breaking_changes(old_schema, new_schema) == [
850835
(BreakingChangeType.TYPE_REMOVED, "Int was removed."),
851836
(BreakingChangeType.TYPE_REMOVED, "TypeInUnion2 was removed."),
852837
(BreakingChangeType.TYPE_REMOVED, "TypeThatGetsRemoved was removed."),
@@ -898,10 +883,6 @@ def should_detect_all_breaking_changes():
898883
),
899884
]
900885

901-
assert (
902-
find_breaking_changes(old_schema, new_schema) == expected_breaking_changes
903-
)
904-
905886
def should_detect_if_a_directive_was_explicitly_removed():
906887
old_schema = build_schema(
907888
"""
@@ -1182,20 +1163,15 @@ def should_detect_if_an_optional_field_was_added_to_an_input():
11821163
"""
11831164
)
11841165

1185-
expected_field_changes = [
1166+
assert find_fields_that_changed_type_on_input_object_types(
1167+
old_schema, new_schema
1168+
).dangerous_changes == [
11861169
(
11871170
DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED,
11881171
"An optional field field2 on input type InputType1 was added.",
11891172
)
11901173
]
11911174

1192-
assert (
1193-
find_fields_that_changed_type_on_input_object_types(
1194-
old_schema, new_schema
1195-
).dangerous_changes
1196-
== expected_field_changes
1197-
)
1198-
11991175
def should_find_all_dangerous_changes():
12001176
old_schema = build_schema(
12011177
"""
@@ -1260,7 +1236,7 @@ def should_find_all_dangerous_changes():
12601236
"""
12611237
)
12621238

1263-
expected_dangerous_changes = [
1239+
assert find_dangerous_changes(old_schema, new_schema) == [
12641240
(
12651241
DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE,
12661242
"Type1.field1 arg name has changed defaultValue",
@@ -1280,10 +1256,6 @@ def should_find_all_dangerous_changes():
12801256
),
12811257
]
12821258

1283-
assert (
1284-
find_dangerous_changes(old_schema, new_schema) == expected_dangerous_changes
1285-
)
1286-
12871259
def should_detect_if_an_optional_field_argument_was_added():
12881260
old_schema = build_schema(
12891261
"""

0 commit comments

Comments
 (0)