Merge "Add `extra_specs` to flavor create JSON schema"

This commit is contained in:
Jenkins 2017-06-19 12:21:07 +00:00 committed by Gerrit Code Review
commit e562918d4f
3 changed files with 5 additions and 2 deletions

View File

@ -22,6 +22,7 @@ create_flavor = {
"properties": {
'name': parameter_types.name,
'description': parameter_types.description,
'extra_specs': parameter_types.metadata,
'is_public': parameter_types.boolean,
'disabled': parameter_types.boolean,
},

View File

@ -38,15 +38,16 @@ class TestFlavor(v1_test.APITestV1):
self.post_json('/flavors', body, headers=self.headers, status=201)
def test_flavor_post(self):
body = {"name": "test", "description": "just test"}
body = {"name": "test", "description": "just test",
"extra_specs": {"k1": "v1"}}
resp = self.post_json(
'/flavors', body, headers=self.headers, status=201)
resp = resp.json
self.assertEqual('test', resp['name'])
self.assertEqual('just test', resp['description'])
self.assertEqual(True, resp['is_public'])
self.assertEqual({'k1': 'v1'}, resp['extra_specs'])
self.assertIn('uuid', resp)
self.assertIn('extra_specs', resp)
self.assertIn('links', resp)
def test_flavor_get_all(self):

View File

@ -165,6 +165,7 @@ def get_test_flavor(**kw):
'uuid': kw.get('uuid', uuidutils.generate_uuid()),
'name': kw.get('name', 'test'),
'description': kw.get('description', 'test'),
'extra_specs': kw.get('extra_specs', {}),
'is_public': kw.get('is_public', 1),
'disabled': kw.get('disabled', 0),
'updated_at': kw.get('updated_at'),