Merge "Add external_network unit test for post baymodel"

This commit is contained in:
Jenkins 2016-03-06 02:50:25 +00:00 committed by Gerrit Code Review
commit b045e3cc8c
1 changed files with 25 additions and 0 deletions

View File

@ -763,6 +763,31 @@ class TestPost(api_base.FunctionalTest):
response = self.post_json('/baymodels', bdict, expect_errors=True)
self.assertEqual(400, response.status_int)
@mock.patch('magnum.api.attr_validator.validate_image')
@mock.patch('magnum.api.attr_validator.validate_os_resources')
def test_create_baymodel_with_external_network(self,
mock_valid_os_res,
mock_image_data):
mock_image_data.return_value = {'name': 'mock_name',
'os_distro': 'fedora-atomic'}
bdict = apiutils.baymodel_post_data()
response = self.post_json('/baymodels', bdict)
self.assertEqual(201, response.status_int)
self.assertEqual(bdict['external_network_id'],
response.json['external_network_id'])
@mock.patch('magnum.api.attr_validator.validate_image')
@mock.patch('magnum.api.attr_validator.validate_os_resources')
def test_create_baymodel_with_no_exist_external_network(self,
mock_valid_os_res,
mock_image_data):
mock_valid_os_res.side_effect = exception.NetworkNotFound("test")
mock_image_data.return_value = {'name': 'mock_name',
'os_distro': 'fedora-atomic'}
bdict = apiutils.baymodel_post_data()
response = self.post_json('/baymodels', bdict, expect_errors=True)
self.assertEqual(400, response.status_int)
class TestDelete(api_base.FunctionalTest):