Fix wrong error message for environment operation
Change-Id: Iafdfef92bd168426be899472f3a722b7b5fcd6cf Closes-Bug: #1620618
This commit is contained in:
parent
64bad97804
commit
872842e771
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,6 +29,7 @@ pip-log.txt
|
||||
nosetests.xml
|
||||
functional_creds.conf
|
||||
AUTHORS
|
||||
ChangeLog
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
|
@ -74,8 +74,11 @@ class ResourceManager(object):
|
||||
def _ensure_not_empty(self, **kwargs):
|
||||
for name, value in kwargs.items():
|
||||
if value is None or (isinstance(value, str) and len(value) == 0):
|
||||
raise APIException('%s is missing field "%s"' %
|
||||
(self.resource_class.__name__, name))
|
||||
raise APIException(
|
||||
400,
|
||||
'%s is missing field "%s"' %
|
||||
(self.resource_class.__name__, name)
|
||||
)
|
||||
|
||||
def _copy_if_defined(self, data, **kwargs):
|
||||
for name, value in kwargs.items():
|
||||
|
@ -19,6 +19,7 @@ import pkg_resources as pkg
|
||||
from six.moves.urllib import parse
|
||||
from six.moves.urllib import request
|
||||
|
||||
from mistralclient.api import base as api_base
|
||||
from mistralclient.api.v2 import environments
|
||||
from mistralclient.tests.unit.v2 import base
|
||||
from mistralclient import utils
|
||||
@ -78,6 +79,15 @@ class TestEnvironmentsV2(base.BaseClientV2Test):
|
||||
|
||||
mock.assert_called_once_with(URL_TEMPLATE, json.dumps(expected_data))
|
||||
|
||||
def test_create_without_name(self):
|
||||
data = copy.deepcopy(ENVIRONMENT)
|
||||
data.pop('name')
|
||||
|
||||
with self.assertRaises(api_base.APIException) as cm:
|
||||
self.environments.create(**data)
|
||||
|
||||
self.assertEqual(400, cm.exception.error_code)
|
||||
|
||||
def test_update(self):
|
||||
data = copy.deepcopy(ENVIRONMENT)
|
||||
|
||||
@ -114,6 +124,15 @@ class TestEnvironmentsV2(base.BaseClientV2Test):
|
||||
|
||||
mock.assert_called_once_with(URL_TEMPLATE, json.dumps(expected_data))
|
||||
|
||||
def test_update_without_name(self):
|
||||
data = copy.deepcopy(ENVIRONMENT)
|
||||
data.pop('name')
|
||||
|
||||
with self.assertRaises(api_base.APIException) as cm:
|
||||
self.environments.update(**data)
|
||||
|
||||
self.assertEqual(400, cm.exception.error_code)
|
||||
|
||||
def test_list(self):
|
||||
mock = self.mock_http_get(content={'environments': [ENVIRONMENT]})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user