mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-28 00:49:49 +03:00
add tests for generateschema command
This commit is contained in:
parent
ce925970b4
commit
f092e55ae1
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user