diff --git a/magnumclient/tests/v1/test_baymodels.py b/magnumclient/tests/v1/test_baymodels.py index 72f95fa2..0e88ee6b 100644 --- a/magnumclient/tests/v1/test_baymodels.py +++ b/magnumclient/tests/v1/test_baymodels.py @@ -17,10 +17,10 @@ import copy import testtools from testtools import matchers +from magnumclient import exceptions from magnumclient.tests import utils from magnumclient.v1 import baymodels - BAYMODEL1 = {'id': 123, 'uuid': '66666666-7777-8888-9999-000000000001', 'name': 'baymodel1', @@ -166,6 +166,15 @@ class BayModelManagerTest(testtools.TestCase): self.assertEqual(BAYMODEL1['docker_volume_size'], baymodel.docker_volume_size) + def test_baymodel_create_fail(self): + CREATE_BAYMODEL_FAIL = copy.deepcopy(CREATE_BAYMODEL) + CREATE_BAYMODEL_FAIL["wrong_key"] = "wrong" + self.assertRaisesRegexp(exceptions.InvalidAttribute, + ("Key must be in %s" % + ','.join(baymodels.CREATION_ATTRIBUTES)), + self.mgr.create, **CREATE_BAYMODEL_FAIL) + self.assertEqual([], self.api.calls) + def test_baymodel_delete_by_id(self): baymodel = self.mgr.delete(BAYMODEL1['id']) expect = [ diff --git a/magnumclient/tests/v1/test_bays.py b/magnumclient/tests/v1/test_bays.py index ec1b7d4f..f0a0d1d0 100644 --- a/magnumclient/tests/v1/test_bays.py +++ b/magnumclient/tests/v1/test_bays.py @@ -17,6 +17,7 @@ import copy import testtools from testtools import matchers +from magnumclient import exceptions from magnumclient.tests import utils from magnumclient.v1 import bays @@ -137,6 +138,15 @@ class BayManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertTrue(bay) + def test_bay_create_fail(self): + CREATE_BAY_FAIL = copy.deepcopy(CREATE_BAY) + CREATE_BAY_FAIL["wrong_key"] = "wrong" + self.assertRaisesRegexp(exceptions.InvalidAttribute, + ("Key must be in %s" % + ','.join(bays.CREATION_ATTRIBUTES)), + self.mgr.create, **CREATE_BAY_FAIL) + self.assertEqual([], self.api.calls) + def test_bay_delete_by_id(self): bay = self.mgr.delete(BAY1['id']) expect = [ diff --git a/magnumclient/tests/v1/test_containers.py b/magnumclient/tests/v1/test_containers.py index 48491384..82b95776 100644 --- a/magnumclient/tests/v1/test_containers.py +++ b/magnumclient/tests/v1/test_containers.py @@ -17,6 +17,7 @@ import copy import testtools from testtools import matchers +from magnumclient import exceptions from magnumclient.tests import utils from magnumclient.v1 import containers @@ -151,6 +152,15 @@ class ContainerManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertTrue(container) + def test_container_create_fail(self): + CREATE_CONTAINER_FAIL = copy.deepcopy(CREATE_CONTAINER) + CREATE_CONTAINER_FAIL["wrong_key"] = "wrong" + self.assertRaisesRegexp(exceptions.InvalidAttribute, + ("Key must be in %s" % + ','.join(containers.CREATION_ATTRIBUTES)), + self.mgr.create, **CREATE_CONTAINER_FAIL) + self.assertEqual([], self.api.calls) + def test_container_delete(self): container = self.mgr.delete(CONTAINER1['id']) expect = [ diff --git a/magnumclient/tests/v1/test_nodes.py b/magnumclient/tests/v1/test_nodes.py index 95d7fc3f..676c558f 100644 --- a/magnumclient/tests/v1/test_nodes.py +++ b/magnumclient/tests/v1/test_nodes.py @@ -17,6 +17,7 @@ import copy import testtools from testtools import matchers +from magnumclient import exceptions from magnumclient.tests import utils from magnumclient.v1 import nodes @@ -105,6 +106,15 @@ class NodeManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertTrue(node) + def test_node_create_fail(self): + CREATE_NODE_FAIL = copy.deepcopy(CREATE_NODE) + CREATE_NODE_FAIL["wrong_key"] = "wrong" + self.assertRaisesRegexp(exceptions.InvalidAttribute, + ("Key must be in %s" % + ','.join(nodes.CREATION_ATTRIBUTES)), + self.mgr.create, **CREATE_NODE_FAIL) + self.assertEqual([], self.api.calls) + def test_node_delete(self): node = self.mgr.delete(NODE1['id']) expect = [ diff --git a/magnumclient/tests/v1/test_pods.py b/magnumclient/tests/v1/test_pods.py index fc53555b..acc4f034 100644 --- a/magnumclient/tests/v1/test_pods.py +++ b/magnumclient/tests/v1/test_pods.py @@ -17,6 +17,7 @@ import copy import testtools from testtools import matchers +from magnumclient import exceptions from magnumclient.tests import utils from magnumclient.v1 import pods @@ -130,6 +131,15 @@ class PodManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertTrue(pod) + def test_pod_create_fail(self): + CREATE_POD_FAIL = copy.deepcopy(CREATE_POD) + CREATE_POD_FAIL["wrong_key"] = "wrong" + self.assertRaisesRegexp(exceptions.InvalidAttribute, + ("Key must be in %s" % + ','.join(pods.CREATION_ATTRIBUTES)), + self.mgr.create, **CREATE_POD_FAIL) + self.assertEqual([], self.api.calls) + def test_pod_delete_by_id(self): pod = self.mgr.delete(POD1['id']) expect = [ diff --git a/magnumclient/tests/v1/test_replicationcontrollers.py b/magnumclient/tests/v1/test_replicationcontrollers.py index c42c6509..688e035d 100644 --- a/magnumclient/tests/v1/test_replicationcontrollers.py +++ b/magnumclient/tests/v1/test_replicationcontrollers.py @@ -17,6 +17,7 @@ import copy import testtools from testtools import matchers +from magnumclient import exceptions from magnumclient.tests import utils from magnumclient.v1 import replicationcontrollers as rcs @@ -128,6 +129,15 @@ class RCManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertTrue(rc) + def test_rc_create_fail(self): + CREATE_RC_FAIL = copy.deepcopy(CREATE_RC) + CREATE_RC_FAIL["wrong_key"] = "wrong" + self.assertRaisesRegexp(exceptions.InvalidAttribute, + ("Key must be in %s" % + ','.join(rcs.CREATION_ATTRIBUTES)), + self.mgr.create, **CREATE_RC_FAIL) + self.assertEqual([], self.api.calls) + def test_rc_delete_by_id(self): rc = self.mgr.delete(RC1['id']) expect = [ diff --git a/magnumclient/tests/v1/test_services.py b/magnumclient/tests/v1/test_services.py index b8340925..90c93885 100644 --- a/magnumclient/tests/v1/test_services.py +++ b/magnumclient/tests/v1/test_services.py @@ -17,6 +17,7 @@ import copy import testtools from testtools import matchers +from magnumclient import exceptions from magnumclient.tests import utils from magnumclient.v1 import services @@ -130,6 +131,15 @@ class ServiceManagerTest(testtools.TestCase): self.assertEqual(expect, self.api.calls) self.assertTrue(service) + def test_service_create_fail(self): + CREATE_SVC_FAIL = copy.deepcopy(CREATE_SVC) + CREATE_SVC_FAIL["wrong_key"] = "wrong" + self.assertRaisesRegexp(exceptions.InvalidAttribute, + ("Key must be in %s" % + ','.join(services.CREATION_ATTRIBUTES)), + self.mgr.create, **CREATE_SVC_FAIL) + self.assertEqual([], self.api.calls) + def test_service_delete_by_id(self): service = self.mgr.delete(SERVICE1['id']) expect = [ diff --git a/magnumclient/v1/baymodels.py b/magnumclient/v1/baymodels.py index d3c3623a..9ede8a98 100644 --- a/magnumclient/v1/baymodels.py +++ b/magnumclient/v1/baymodels.py @@ -89,7 +89,8 @@ class BayModelManager(base.Manager): if key in CREATION_ATTRIBUTES: new[key] = value else: - raise exceptions.InvalidAttribute() + raise exceptions.InvalidAttribute( + "Key must be in %s" % ",".join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) def delete(self, id): diff --git a/magnumclient/v1/bays.py b/magnumclient/v1/bays.py index caf5c295..e2ee4e3d 100644 --- a/magnumclient/v1/bays.py +++ b/magnumclient/v1/bays.py @@ -88,7 +88,8 @@ class BayManager(base.Manager): if key in CREATION_ATTRIBUTES: new[key] = value else: - raise exceptions.InvalidAttribute() + raise exceptions.InvalidAttribute( + "Key must be in %s" % ",".join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) def delete(self, id): diff --git a/magnumclient/v1/containers.py b/magnumclient/v1/containers.py index 0a17b56c..3d02cd4d 100644 --- a/magnumclient/v1/containers.py +++ b/magnumclient/v1/containers.py @@ -94,7 +94,8 @@ class ContainerManager(base.Manager): if key in CREATION_ATTRIBUTES: new[key] = value else: - raise exceptions.InvalidAttribute() + raise exceptions.InvalidAttribute( + "Key must be in %s" % ','.join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) def delete(self, id): diff --git a/magnumclient/v1/nodes.py b/magnumclient/v1/nodes.py index 6e3809a2..ccc38dd4 100644 --- a/magnumclient/v1/nodes.py +++ b/magnumclient/v1/nodes.py @@ -88,7 +88,8 @@ class NodeManager(base.Manager): if key in CREATION_ATTRIBUTES: new[key] = value else: - raise exceptions.InvalidAttribute() + raise exceptions.InvalidAttribute( + "Key must be in %s" % ",".join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) def delete(self, id): diff --git a/magnumclient/v1/pods.py b/magnumclient/v1/pods.py index c7b0ac8e..0c3a8bd3 100644 --- a/magnumclient/v1/pods.py +++ b/magnumclient/v1/pods.py @@ -88,7 +88,8 @@ class PodManager(base.Manager): if key in CREATION_ATTRIBUTES: new[key] = value else: - raise exceptions.InvalidAttribute() + raise exceptions.InvalidAttribute( + "Key must be in %s" % ",".join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) def delete(self, id): diff --git a/magnumclient/v1/replicationcontrollers.py b/magnumclient/v1/replicationcontrollers.py index b6a6544b..63e8b2d1 100644 --- a/magnumclient/v1/replicationcontrollers.py +++ b/magnumclient/v1/replicationcontrollers.py @@ -88,7 +88,8 @@ class ReplicationControllerManager(base.Manager): if key in CREATION_ATTRIBUTES: new[key] = value else: - raise exceptions.InvalidAttribute() + raise exceptions.InvalidAttribute( + "Key must be in %s" % ",".join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) def delete(self, id): diff --git a/magnumclient/v1/services.py b/magnumclient/v1/services.py index dbacd476..a422ac3d 100644 --- a/magnumclient/v1/services.py +++ b/magnumclient/v1/services.py @@ -87,7 +87,8 @@ class ServiceManager(base.Manager): if key in CREATION_ATTRIBUTES: new[key] = value else: - raise exceptions.InvalidAttribute() + raise exceptions.InvalidAttribute( + "Key must be in %s" % ",".join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) def delete(self, service_id):