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