From f092e55ae162d1c5cb4611fdddf5f64a09220a25 Mon Sep 17 00:00:00 2001 From: Dhaval Mehta <20968146+dhaval-mehta@users.noreply.github.com> Date: Tue, 26 May 2020 02:30:20 +0530 Subject: [PATCH] add tests for generateschema command --- tests/schemas/test_managementcommand.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/schemas/test_managementcommand.py b/tests/schemas/test_managementcommand.py index 115f871e5..392848a04 100644 --- a/tests/schemas/test_managementcommand.py +++ b/tests/schemas/test_managementcommand.py @@ -149,3 +149,28 @@ class GenerateSchemaTests(TestCase): '--format=corejson', stdout=self.out) self.assertIn(expected_out, self.out.getvalue()) + + def test_accepts_tag_objects(self): + tag_objects = '[{"name": "pet", "description": "Pets operations"}, {"name": "store", "description": "Store ' \ + 'operations"}]' + call_command('generateschema', + '--tag_objects={}'.format(tag_objects), + stdout=self.out) + out_json = yaml.safe_load(self.out.getvalue()) + assert out_json['tags'] == [ + { + "name": "pet", + "description": "Pets operations" + }, + { + "name": "store", + "description": "Store operations" + } + ] + + def test_rejects_invalid_tag_objects(self): + tag_objects = '[{"name": "pet", "description": "Pets operations"}' + with pytest.raises(SyntaxError): + call_command('generateschema', + '--tag_objects={}'.format(tag_objects), + stdout=self.out)