Merge "A bay without name should be successfully created"

This commit is contained in:
Jenkins 2016-01-13 04:41:10 +00:00 committed by Gerrit Code Review
commit 24e05933de
2 changed files with 11 additions and 0 deletions

View File

@ -284,6 +284,8 @@ class BaysController(rest.RestController):
# NOTE(suro-patz): Apply default node_count is 1, None -> 1
if bay_dict.get('node_count', None) is None:
bay_dict['node_count'] = 1
if bay_dict.get('name', None) is None:
bay_dict['name'] = None
new_bay = objects.Bay(context, **bay_dict)
res_bay = pecan.request.rpcapi.bay_create(new_bay,

View File

@ -535,6 +535,15 @@ class TestPost(api_base.FunctionalTest):
self.assertEqual(400, response.status_int)
self.assertTrue(response.json['error_message'])
@mock.patch('magnum.api.attr_validator.validate_os_resources')
def test_create_bay_without_name(self, mock_valid_os_res):
bdict = apiutils.bay_post_data()
del bdict['name']
mock_valid_os_res.return_value = None
response = self.post_json('/bays', bdict, expect_errors=True)
self.assertEqual('application/json', response.content_type)
self.assertEqual(201, response.status_int)
@mock.patch('magnum.api.attr_validator.validate_os_resources')
def test_create_bay_with_timeout_none(self, mock_valid_os_res):
bdict = apiutils.bay_post_data()