Browse Source

Add flavor_id unit test for post baymodel

Change-Id: I0215a89cb98421fb2845b75d5ec6308c87f99591
changes/22/286422/2
wangqun 5 years ago
parent
commit
c693cabf87
1 changed files with 28 additions and 0 deletions
  1. +28
    -0
      magnum/tests/unit/api/controllers/v1/test_baymodel.py

+ 28
- 0
magnum/tests/unit/api/controllers/v1/test_baymodel.py View File

@ -736,6 +736,34 @@ class TestPost(api_base.FunctionalTest):
response = self.post_json('/baymodels', bdict, expect_errors=True)
self.assertEqual(404, 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_flavor(self,
mock_valid_os_res,
mock_image_data):
mock_valid_os_res.return_value = None
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['flavor_id'],
response.json['flavor_id'])
self.assertEqual(bdict['master_flavor_id'],
response.json['master_flavor_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_flavor(self,
mock_valid_os_res,
mock_image_data):
mock_valid_os_res.side_effect = exception.FlavorNotFound("flavor_id")
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):


Loading…
Cancel
Save