Make schema also be pretty-printed by default for easier diffs.

This commit is contained in:
Gary Donovan 2019-03-27 08:29:24 +11:00
parent 1ca44b55cb
commit 6c1a301423
2 changed files with 3 additions and 2 deletions

View File

@ -28,7 +28,7 @@ except ImportError:
DEFAULTS = { DEFAULTS = {
"SCHEMA": None, "SCHEMA": None,
"SCHEMA_OUTPUT": "schema.json", "SCHEMA_OUTPUT": "schema.json",
"SCHEMA_INDENT": None, "SCHEMA_INDENT": 2,
"MIDDLEWARE": (), "MIDDLEWARE": (),
# Set to True if the connection fields must have # Set to True if the connection fields must have
# either the first or last argument # either the first or last argument

View File

@ -11,7 +11,7 @@ def test_generate_file_on_call_graphql_schema(savefile_mock, settings):
@patch('json.dump') @patch('json.dump')
def test_files_are_sorted(dump_mock): def test_files_are_canonical(dump_mock):
open_mock = mock_open() open_mock = mock_open()
with patch('graphene_django.management.commands.graphql_schema.open', open_mock): with patch('graphene_django.management.commands.graphql_schema.open', open_mock):
management.call_command('graphql_schema', schema='') management.call_command('graphql_schema', schema='')
@ -20,3 +20,4 @@ def test_files_are_sorted(dump_mock):
dump_mock.assert_called_once() dump_mock.assert_called_once()
assert dump_mock.call_args[1]["sort_keys"], "json.mock() should be used to sort the output" assert dump_mock.call_args[1]["sort_keys"], "json.mock() should be used to sort the output"
assert dump_mock.call_args[1]["indent"] > 0, "output should be pretty-printed by default"