summaryrefslogtreecommitdiff
path: root/heat
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2014-08-01 17:50:52 +0000
committerGerrit Code Review <review@openstack.org>2014-08-01 17:50:52 +0000
commitbb7cc368d974780ee8ed3e4e3ff4bed84ad1d7f7 (patch)
treefe98261ae1c2d93bed9ae47b4b6774ca609d5719 /heat
parent39a16683d32f91c2e28751213cf3f78f02d88846 (diff)
parentbd4ed52b78dc20759b0780e2fcece409c423f1d4 (diff)
downloadheat-bb7cc368d974780ee8ed3e4e3ff4bed84ad1d7f7.tar.gz
Merge "Move novaclient exceptions to heat.tests.v1_1.fakes" into stable/icehouse
Diffstat (limited to 'heat')
-rw-r--r--heat/tests/test_nova_utils.py11
-rw-r--r--heat/tests/test_security_group.py12
-rw-r--r--heat/tests/v1_1/fakes.py10
3 files changed, 17 insertions, 16 deletions
diff --git a/heat/tests/test_nova_utils.py b/heat/tests/test_nova_utils.py
index 3e382ba91..a4d881fcc 100644
--- a/heat/tests/test_nova_utils.py
+++ b/heat/tests/test_nova_utils.py
@@ -20,6 +20,7 @@ from heat.common import exception
from heat.engine import clients
from heat.engine.resources import nova_utils
from heat.tests.common import HeatTestCase
+from heat.tests.v1_1 import fakes
class NovaUtilsTests(HeatTestCase):
@@ -126,10 +127,7 @@ class NovaUtilsRefreshServerTests(HeatTestCase):
def test_500_error(self):
server = self.m.CreateMockAnything()
- msg = ("ClientException: The server has either erred or is "
- "incapable of performing the requested operation.")
- server.get().AndRaise(
- clients.novaclient.exceptions.ClientException(500, msg))
+ server.get().AndRaise(fakes.fake_exception(500))
self.m.ReplayAll()
self.assertIsNone(nova_utils.refresh_server(server))
@@ -137,10 +135,7 @@ class NovaUtilsRefreshServerTests(HeatTestCase):
def test_503_error(self):
server = self.m.CreateMockAnything()
- msg = ("ClientException: The server has either erred or is "
- "incapable of performing the requested operation.")
- server.get().AndRaise(
- clients.novaclient.exceptions.ClientException(503, msg))
+ server.get().AndRaise(fakes.fake_exception(503))
self.m.ReplayAll()
self.assertIsNone(nova_utils.refresh_server(server))
diff --git a/heat/tests/test_security_group.py b/heat/tests/test_security_group.py
index b5794205a..09ab32041 100644
--- a/heat/tests/test_security_group.py
+++ b/heat/tests/test_security_group.py
@@ -361,20 +361,16 @@ Resources:
clients.OpenStackClients.nova('compute').AndReturn(self.fc)
nova_sgr.SecurityGroupRuleManager.create(
2, 'tcp', '22', '22', '0.0.0.0/0', None).AndRaise(
- clients.novaclient.exceptions.BadRequest(
- 400, 'Rule already exists'))
+ fakes.fake_exception(400, 'Rule already exists'))
nova_sgr.SecurityGroupRuleManager.create(
2, 'tcp', '80', '80', '0.0.0.0/0', None).AndReturn(
- clients.novaclient.exceptions.BadRequest(
- 400, 'Rule already exists'))
+ fakes.fake_exception(400, 'Rule already exists'))
nova_sgr.SecurityGroupRuleManager.create(
2, 'tcp', None, None, None, 1).AndReturn(
- clients.novaclient.exceptions.BadRequest(
- 400, 'Rule already exists'))
+ fakes.fake_exception(400, 'Rule already exists'))
nova_sgr.SecurityGroupRuleManager.create(
2, 'icmp', None, None, None, '1').AndReturn(
- clients.novaclient.exceptions.BadRequest(
- 400, 'Rule already exists'))
+ fakes.fake_exception(400, 'Rule already exists'))
# delete script
clients.OpenStackClients.nova('compute').AndReturn(self.fc)
diff --git a/heat/tests/v1_1/fakes.py b/heat/tests/v1_1/fakes.py
index cd20a4d10..04e95154b 100644
--- a/heat/tests/v1_1/fakes.py
+++ b/heat/tests/v1_1/fakes.py
@@ -14,14 +14,24 @@
# limitations under the License.
import httplib2
+import mock
from novaclient import client as base_client
+from novaclient import exceptions as nova_exceptions
from novaclient.v1_1 import client
from heat.openstack.common.py3kcompat import urlutils
from heat.tests import fakes
+def fake_exception(status_code=404, message=None, details=None):
+ resp = mock.Mock()
+ resp.status_code = status_code
+ resp.headers = None
+ body = {'error': {'message': message, 'details': details}}
+ return nova_exceptions.from_response(resp, body, None)
+
+
class FakeClient(fakes.FakeClient, client.Client):
def __init__(self, *args, **kwargs):