diff --git a/graphql_compiler/tests/test_schema.py b/graphql_compiler/tests/test_schema.py index 666230877..ccd7f02c8 100644 --- a/graphql_compiler/tests/test_schema.py +++ b/graphql_compiler/tests/test_schema.py @@ -7,12 +7,14 @@ import unittest from graphql.type import GraphQLField, GraphQLInt, GraphQLObjectType, GraphQLSchema, GraphQLString -from graphql.utilities import print_schema +from graphql.utilities import print_schema, lexicographic_sort_schema import pytz import six from .. import schema from .test_helpers import get_schema +from copy import deepcopy +from graphql import build_schema class SchemaTests(unittest.TestCase): @@ -140,3 +142,31 @@ def test_meta_fields_from_constant(self): " ", " " ) # 2 space indentation instead of 4 spaces self.assertIn(expected_type_definition, printed_schema) + + def test_normal_schema_comparison(self): + self.assertEqual( + print_schema(lexicographic_sort_schema(get_schema())), + print_schema(lexicographic_sort_schema(get_schema())) + ) + + def test_deep_copy_comparison(self): + SCHEMA_TEXT = """ + schema { + query: RootSchemaQuery + } + + type Animal { + uuid: ID + } + + type RootSchemaQuery { + Animal: [Animal] + } + """ + graphql_schema = build_schema(SCHEMA_TEXT) + graphql_schema_copy = deepcopy(graphql_schema) + + self.assertEqual( + print_schema(lexicographic_sort_schema(graphql_schema)), + print_schema(lexicographic_sort_schema(graphql_schema_copy)) + )