tests: Pre-mox removal cleanup
Move some stuff around in order to make the later migration easier to
parse.
MODIFY
heatclient/tests/unit/test_resources.py
heatclient/tests/unit/test_resources.py
@@ -20,28 +20,23 @@ from heatclient.common import utils
from heatclient.v1 import resources
-class ResourceManagerTest(testtools.TestCase):
-
- def setUp(self):
- super(ResourceManagerTest, self).setUp()
- self.m = mox.Mox()
- self.addCleanup(self.m.UnsetStubs)
-
- def _base_test(self, expect, key):
-
class FakeAPI(object):
"""Fake API and ensure request url is correct."""
+ def __init__(self, expect, key):
+ self.expect = expect
+ self.key = key
+
def get(self, *args, **kwargs):
- assert ('GET', args[0]) == expect
+ assert ('GET', args[0]) == self.expect
def json_request(self, *args, **kwargs):
- assert args == expect
- ret = key and {key: []} or {}
- return {}, {key: ret}
+ assert args == self.expect
+ ret = self.key and {self.key: []} or {}
+ return {}, {self.key: ret}
def raw_request(self, *args, **kwargs):
- assert args == expect
+ assert args == self.expect
return {}
def head(self, url, **kwargs):
@@ -59,7 +54,16 @@ class ResourceManagerTest(testtools.TestCase):
def patch(self, url, **kwargs):
return self.json_request("PATCH", url, **kwargs)
- manager = resources.ResourceManager(FakeAPI())
+
+class ResourceManagerTest(testtools.TestCase):
+
+ def setUp(self):
+ super(ResourceManagerTest, self).setUp()
+ self.m = mox.Mox()
+ self.addCleanup(self.m.UnsetStubs)
+
+ def _base_test(self, expect, key):
+ manager = resources.ResourceManager(FakeAPI(expect, key))
self.m.StubOutWithMock(manager, '_resolve_stack_id')
self.m.StubOutWithMock(utils, 'get_response_body')
utils.get_response_body(mox.IgnoreArg()).AndReturn(
@@ -106,6 +110,21 @@ class ResourceManagerTest(testtools.TestCase):
manager.get(**fields)
self.m.VerifyAll()
+ def _test_list(self, fields, expect):
+ key = 'resources'
+
+ class FakeResponse(object):
+ def json(self):
+ return {key: {}}
+
+ class FakeClient(object):
+ def get(self, *args, **kwargs):
+ assert args[0] == expect
+ return FakeResponse()
+
+ manager = resources.ResourceManager(FakeClient())
+ manager.list(**fields)
+
def test_list(self):
self._test_list(
fields={'stack_id': 'teststack'},
@@ -135,21 +154,6 @@ class ResourceManagerTest(testtools.TestCase):
}, True)
)
- def _test_list(self, fields, expect):
- key = 'resources'
-
- class FakeResponse(object):
- def json(self):
- return {key: {}}
-
- class FakeClient(object):
- def get(self, *args, **kwargs):
- assert args[0] == expect
- return FakeResponse()
-
- manager = resources.ResourceManager(FakeClient())
- manager.list(**fields)
-
def test_metadata(self):
fields = {'stack_id': 'teststack',
'resource_name': 'testresource'}

tests: Pre-mox removal cleanup

Move some stuff around in order to make the later migration easier to
parse.

Change-Id: I1404a5b23fd1852be9d04661c2a0ba12c4bb78ec
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>