summaryrefslogtreecommitdiff
path: root/heat/tests
diff options
context:
space:
mode:
authorClint Byrum <clint@fewbar.com>2013-04-26 15:49:33 -0700
committerClint Byrum <clint@fewbar.com>2013-04-30 13:51:31 -0700
commit2c4eea5500691a7cbc84fc0273a5a79bc03fe78d (patch)
treeffdf6778b9da77d60415f60b047b00777ec243c9 /heat/tests
parentfb6de9419fe729f2a46dcb10ce6191439d933218 (diff)
downloadheat-2c4eea5500691a7cbc84fc0273a5a79bc03fe78d.tar.gz
Remove use of nose attrib plugin and most unittest
Some simple cases that do not use mox still use unittest directly. Replacing unittest.TestCase with HeatTestCase has the added benefit of capturing all logging for reporting during failure. Change-Id: I76192bdb91822055f1e2f7d2e806bf094d399304
Diffstat (limited to 'heat/tests')
-rw-r--r--heat/tests/test_api_aws.py4
-rw-r--r--heat/tests/test_api_cfn_v1.py3
-rw-r--r--heat/tests/test_api_cloudwatch.py3
-rw-r--r--heat/tests/test_api_openstack_v1.py44
-rw-r--r--heat/tests/test_autoscaling.py13
-rw-r--r--heat/tests/test_cli.py3
-rw-r--r--heat/tests/test_common_policy.py13
-rw-r--r--heat/tests/test_dbinstance.py4
-rw-r--r--heat/tests/test_dependencies.py3
-rw-r--r--heat/tests/test_eip.py15
-rw-r--r--heat/tests/test_engine_api_utils.py3
-rw-r--r--heat/tests/test_engine_service.py129
-rw-r--r--heat/tests/test_event.py14
-rw-r--r--heat/tests/test_identifier.py7
-rw-r--r--heat/tests/test_instance.py13
-rw-r--r--heat/tests/test_instance_group.py13
-rw-r--r--heat/tests/test_loadbalancer.py4
-rw-r--r--heat/tests/test_loguserdata.py14
-rw-r--r--heat/tests/test_metadata_refresh.py24
-rw-r--r--heat/tests/test_nested_stack.py4
-rw-r--r--heat/tests/test_nokey.py15
-rw-r--r--heat/tests/test_parameters.py5
-rw-r--r--heat/tests/test_parser.py29
-rw-r--r--heat/tests/test_plugin_loader.py3
-rw-r--r--heat/tests/test_properties.py7
-rw-r--r--heat/tests/test_quantum.py28
-rw-r--r--heat/tests/test_resource.py22
-rw-r--r--heat/tests/test_rpc_client.py5
-rw-r--r--heat/tests/test_s3.py13
-rw-r--r--heat/tests/test_security_group.py14
-rw-r--r--heat/tests/test_short_id.py3
-rw-r--r--heat/tests/test_swift.py13
-rw-r--r--heat/tests/test_template_format.py9
-rw-r--r--heat/tests/test_urlfetch.py13
-rw-r--r--heat/tests/test_user.py17
-rw-r--r--heat/tests/test_validate.py15
-rw-r--r--heat/tests/test_volume.py4
-rw-r--r--heat/tests/test_vpc.py28
-rw-r--r--heat/tests/test_waitcondition.py22
-rw-r--r--heat/tests/test_watch.py13
40 files changed, 164 insertions, 444 deletions
diff --git a/heat/tests/test_api_aws.py b/heat/tests/test_api_aws.py
index a54a5eb67..093d655ba 100644
--- a/heat/tests/test_api_aws.py
+++ b/heat/tests/test_api_aws.py
@@ -14,13 +14,9 @@
from heat.tests.common import HeatTestCase
-from nose.plugins.attrib import attr
-
from heat.api.aws import utils as api_utils
-@attr(tag=['unit', 'api-aws', 'AWSCommon'])
-@attr(speed='fast')
class AWSCommon(HeatTestCase):
'''
Tests the api/aws common componenents
diff --git a/heat/tests/test_api_cfn_v1.py b/heat/tests/test_api_cfn_v1.py
index a13363f95..6ec9c4a8c 100644
--- a/heat/tests/test_api_cfn_v1.py
+++ b/heat/tests/test_api_cfn_v1.py
@@ -15,7 +15,6 @@
import json
import os
-from nose.plugins.attrib import attr
from oslo.config import cfg
from heat.common import context
@@ -32,8 +31,6 @@ from heat.tests.common import HeatTestCase
policy_path = os.path.dirname(os.path.realpath(__file__)) + "/policy/"
-@attr(tag=['unit', 'api-cfn-v1-stacks', 'StackController'])
-@attr(speed='fast')
class CfnStackControllerTest(HeatTestCase):
'''
Tests the API class which acts as the WSGI controller,
diff --git a/heat/tests/test_api_cloudwatch.py b/heat/tests/test_api_cloudwatch.py
index ed189c68a..82c46e90e 100644
--- a/heat/tests/test_api_cloudwatch.py
+++ b/heat/tests/test_api_cloudwatch.py
@@ -14,7 +14,6 @@
import os
-from nose.plugins.attrib import attr
from oslo.config import cfg
from heat.common import context
@@ -27,8 +26,6 @@ from heat.rpc import api as engine_api
from heat.tests.common import HeatTestCase
-@attr(tag=['unit', 'api-cloudwatch', 'WatchController'])
-@attr(speed='fast')
class WatchControllerTest(HeatTestCase):
'''
Tests the API class which acts as the WSGI controller,
diff --git a/heat/tests/test_api_openstack_v1.py b/heat/tests/test_api_openstack_v1.py
index 76909000a..39946fdd6 100644
--- a/heat/tests/test_api_openstack_v1.py
+++ b/heat/tests/test_api_openstack_v1.py
@@ -13,10 +13,7 @@
# under the License.
import json
-import unittest
-import mox
-from nose.plugins.attrib import attr
from oslo.config import cfg
import webob.exc
@@ -27,6 +24,7 @@ import heat.openstack.common.rpc.common as rpc_common
from heat.common.wsgi import Request
from heat.common import urlfetch
from heat.rpc import api as rpc_api
+from heat.tests.common import HeatTestCase
import heat.api.openstack.v1 as api_v1
import heat.api.openstack.v1.stacks as stacks
@@ -34,15 +32,7 @@ import heat.api.openstack.v1.resources as resources
import heat.api.openstack.v1.events as events
-@attr(tag=['unit', 'api-openstack-v1'])
-@attr(speed='fast')
-class InstantiationDataTest(unittest.TestCase):
-
- def setUp(self):
- self.m = mox.Mox()
-
- def tearDown(self):
- self.m.UnsetStubs()
+class InstantiationDataTest(HeatTestCase):
def test_format_parse(self):
data = {"key1": ["val1[0]", "val1[1]"], "key2": "val2"}
@@ -156,17 +146,11 @@ class ControllerTest(object):
def __init__(self, *args, **kwargs):
super(ControllerTest, self).__init__(*args, **kwargs)
- self.maxDiff = None
- self.m = mox.Mox()
-
cfg.CONF.set_default('host', 'host')
self.topic = rpc_api.ENGINE_TOPIC
self.api_version = '1.0'
self.tenant = 't'
- def tearDown(self):
- self.m.UnsetStubs()
-
def _create_context(self, user='api_test_user'):
ctx = context.get_admin_context()
self.m.StubOutWithMock(ctx, 'username')
@@ -220,18 +204,19 @@ class ControllerTest(object):
return 'http://%s%s' % (host, path)
-@attr(tag=['unit', 'api-openstack-v1', 'StackController'])
-@attr(speed='fast')
-class StackControllerTest(ControllerTest, unittest.TestCase):
+class StackControllerTest(ControllerTest, HeatTestCase):
'''
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
def setUp(self):
+ super(StackControllerTest, self).setUp()
# Create WSGI controller instance
+
class DummyConfig():
bind_port = 8004
+
cfgopts = DummyConfig()
self.controller = stacks.StackController(options=cfgopts)
@@ -894,18 +879,19 @@ class StackControllerTest(ControllerTest, unittest.TestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'api-openstack-v1', 'ResourceController'])
-@attr(speed='fast')
-class ResourceControllerTest(ControllerTest, unittest.TestCase):
+class ResourceControllerTest(ControllerTest, HeatTestCase):
'''
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
def setUp(self):
+ super(ResourceControllerTest, self).setUp()
# Create WSGI controller instance
+
class DummyConfig():
bind_port = 8004
+
cfgopts = DummyConfig()
self.controller = resources.ResourceController(options=cfgopts)
@@ -1211,18 +1197,19 @@ class ResourceControllerTest(ControllerTest, unittest.TestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'api-openstack-v1', 'EventController'])
-@attr(speed='fast')
-class EventControllerTest(ControllerTest, unittest.TestCase):
+class EventControllerTest(ControllerTest, HeatTestCase):
'''
Tests the API class which acts as the WSGI controller,
the endpoint processing API requests after they are routed
'''
def setUp(self):
+ super(EventControllerTest, self).setUp()
# Create WSGI controller instance
+
class DummyConfig():
bind_port = 8004
+
cfgopts = DummyConfig()
self.controller = events.EventController(options=cfgopts)
@@ -1612,7 +1599,7 @@ class EventControllerTest(ControllerTest, unittest.TestCase):
self.m.VerifyAll()
-class RoutesTest(unittest.TestCase):
+class RoutesTest(HeatTestCase):
def assertRoute(self, mapper, path, method, action, controller, params={}):
route = mapper.match(path, {'REQUEST_METHOD': method})
@@ -1625,6 +1612,7 @@ class RoutesTest(unittest.TestCase):
self.assertEqual(params, route)
def setUp(self):
+ super(RoutesTest, self).setUp()
self.m = api_v1.API({}).map
def test_template_handling(self):
diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py
index de28c6edd..a1b937f39 100644
--- a/heat/tests/test_autoscaling.py
+++ b/heat/tests/test_autoscaling.py
@@ -18,11 +18,8 @@ import datetime
import copy
import eventlet
-import unittest
import mox
-from nose.plugins.attrib import attr
-
from heat.common import context
from heat.common import template_format
from heat.engine.resources import autoscaling as asc
@@ -32,19 +29,15 @@ from heat.engine import parser
from heat.engine import scheduler
from heat.engine.resource import Metadata
from heat.openstack.common import timeutils
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class AutoScalingTest(unittest.TestCase):
+class AutoScalingTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(AutoScalingTest, self).setUp()
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def load_template(self):
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
diff --git a/heat/tests/test_cli.py b/heat/tests/test_cli.py
index 753b90e26..934bfdf58 100644
--- a/heat/tests/test_cli.py
+++ b/heat/tests/test_cli.py
@@ -13,7 +13,6 @@
# under the License.
-from nose.plugins.attrib import attr
import unittest
import heat
import os
@@ -22,8 +21,6 @@ import subprocess
basepath = os.path.join(heat.__path__[0], os.path.pardir)
-@attr(tag=['unit', 'cli'])
-@attr(speed='medium')
class CliTest(unittest.TestCase):
def test_bins(self):
diff --git a/heat/tests/test_common_policy.py b/heat/tests/test_common_policy.py
index af8bb0534..66a7c3363 100644
--- a/heat/tests/test_common_policy.py
+++ b/heat/tests/test_common_policy.py
@@ -15,21 +15,17 @@
import os.path
-import mox
-from nose.plugins.attrib import attr
from oslo.config import cfg
-import unittest
from heat.common import context
from heat.common import policy
from heat.common import exception
+from heat.tests.common import HeatTestCase
policy_path = os.path.dirname(os.path.realpath(__file__)) + "/policy/"
-@attr(tag=['unit', 'common-policy', 'Enforcer'])
-@attr(speed='fast')
-class TestPolicyEnforcer(unittest.TestCase):
+class TestPolicyEnforcer(HeatTestCase):
cfn_actions = ("ListStacks", "CreateStack", "DescribeStacks",
"DeleteStack", "UpdateStack", "DescribeStackEvents",
"ValidateTemplate", "GetTemplate",
@@ -42,7 +38,7 @@ class TestPolicyEnforcer(unittest.TestCase):
"PutMetricAlarm", "PutMetricData", "SetAlarmState")
def setUp(self):
- self.m = mox.Mox()
+ super(TestPolicyEnforcer, self).setUp()
opts = [
cfg.StrOpt('config_dir', default=policy_path),
cfg.StrOpt('config_file', default='foo'),
@@ -50,9 +46,6 @@ class TestPolicyEnforcer(unittest.TestCase):
]
cfg.CONF.register_opts(opts)
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_policy_cfn_default(self):
enforcer = policy.Enforcer(scope='cloudformation')
diff --git a/heat/tests/test_dbinstance.py b/heat/tests/test_dbinstance.py
index dfea60075..2d815fbcf 100644
--- a/heat/tests/test_dbinstance.py
+++ b/heat/tests/test_dbinstance.py
@@ -17,8 +17,6 @@ import os
import mox
-from nose.plugins.attrib import attr
-
from heat.common import context
from heat.common import exception
from heat.common import template_format
@@ -28,8 +26,6 @@ from heat.engine.resources import dbinstance as dbi
from heat.tests.common import HeatTestCase
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class DBInstanceTest(HeatTestCase):
def setUp(self):
super(DBInstanceTest, self).setUp()
diff --git a/heat/tests/test_dependencies.py b/heat/tests/test_dependencies.py
index 36a191261..ec2f546e1 100644
--- a/heat/tests/test_dependencies.py
+++ b/heat/tests/test_dependencies.py
@@ -14,14 +14,11 @@
import unittest
-from nose.plugins.attrib import attr
from heat.engine.dependencies import Dependencies
from heat.engine.dependencies import CircularDependencyException
-@attr(tag=['unit', 'dependencies'])
-@attr(speed='fast')
class dependenciesTest(unittest.TestCase):
def _dep_test(self, func, checkorder, deps):
diff --git a/heat/tests/test_eip.py b/heat/tests/test_eip.py
index 9007d3443..5aa01d20e 100644
--- a/heat/tests/test_eip.py
+++ b/heat/tests/test_eip.py
@@ -15,34 +15,25 @@
import os
-import unittest
-import mox
-
-from nose.plugins.attrib import attr
-
from heat.common import context
from heat.common import template_format
from heat.engine.resources import eip
from heat.engine import parser
from heat.engine import scheduler
+from heat.tests.common import HeatTestCase
from heat.tests.v1_1 import fakes
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class EIPTest(unittest.TestCase):
+class EIPTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(EIPTest, self).setUp()
self.fc = fakes.FakeClient()
self.m.StubOutWithMock(eip.ElasticIp, 'nova')
self.m.StubOutWithMock(eip.ElasticIpAssociation, 'nova')
self.m.StubOutWithMock(self.fc.servers, 'get')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def load_template(self):
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
diff --git a/heat/tests/test_engine_api_utils.py b/heat/tests/test_engine_api_utils.py
index 801748f8a..f9305b2eb 100644
--- a/heat/tests/test_engine_api_utils.py
+++ b/heat/tests/test_engine_api_utils.py
@@ -14,13 +14,10 @@
import unittest
-from nose.plugins.attrib import attr
import heat.engine.api as api
-@attr(tag=['unit', 'engine-api'])
-@attr(speed='fast')
class EngineApiTest(unittest.TestCase):
def test_timeout_extract(self):
p = {'timeout_mins': '5'}
diff --git a/heat/tests/test_engine_service.py b/heat/tests/test_engine_service.py
index cd2d473ff..de2655577 100644
--- a/heat/tests/test_engine_service.py
+++ b/heat/tests/test_engine_service.py
@@ -14,11 +14,9 @@
import os
-import unittest
import json
import mox
-from nose.plugins.attrib import attr
from oslo.config import cfg
from heat.common import context
@@ -34,6 +32,7 @@ from heat.engine.properties import Properties
from heat.engine.resources import instance as instances
from heat.engine import watchrule
from heat.openstack.common import threadgroup
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
@@ -104,16 +103,11 @@ class DummyThreadGroup(object):
pass
-@attr(tag=['unit', 'stack'])
-@attr(speed='slow')
-class stackCreateTest(unittest.TestCase):
+class stackCreateTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(stackCreateTest, self).setUp()
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_wordpress_single_instance_stack_create(self):
stack = get_wordpress_stack('test_stack', create_context(self.m))
setup_mocks(self.m, stack)
@@ -151,12 +145,10 @@ class stackCreateTest(unittest.TestCase):
self.assertEqual(db_s.status, 'DELETE_COMPLETE')
-@attr(tag=['unit', 'engine-api', 'engine-service'])
-@attr(speed='fast')
-class stackServiceCreateUpdateDeleteTest(unittest.TestCase):
+class stackServiceCreateUpdateDeleteTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(stackServiceCreateUpdateDeleteTest, self).setUp()
self.username = 'stack_service_create_test_user'
self.tenant = 'stack_service_create_test_tenant'
setup_dummy_db()
@@ -164,9 +156,6 @@ class stackServiceCreateUpdateDeleteTest(unittest.TestCase):
self.man = service.EngineService('a-host', 'a-topic')
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_stack_create(self):
stack_name = 'service_create_test_stack'
params = {'foo': 'bar'}
@@ -396,58 +385,63 @@ class stackServiceCreateUpdateDeleteTest(unittest.TestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'engine-api', 'engine-service'])
-@attr(speed='fast')
-class stackServiceTest(unittest.TestCase):
- @classmethod
- def setUpClass(cls):
+class stackServiceTestBase(HeatTestCase):
+
+ tenant = 'stack_service_test_tenant'
+
+ def tearDown(self):
+ super(stackServiceTestBase, self).tearDown()
+ # testtools runs cleanups *after* tearDown, but we need to mock some
+ # things now.
+ self.m.UnsetStubs()
+
+ m = mox.Mox()
+ create_context(m, self.username, self.tenant, ctx=self.stack.context)
+ fc = setup_mocks(m, self.stack)
+ m.StubOutWithMock(fc.client, 'get_servers_9999')
+ get = fc.client.get_servers_9999
+ get().AndRaise(service.clients.novaclient.exceptions.NotFound(404))
+ m.ReplayAll()
+
+ self.stack.delete()
+
+ m.UnsetStubs()
+
+ def setUp(self):
+ setup_dummy_db()
m = mox.Mox()
- cls.username = 'stack_service_test_user'
- cls.tenant = 'stack_service_test_tenant'
- ctx = create_context(m, cls.username, cls.tenant)
- cls.stack_name = 'service_test_stack'
+ self.username = 'stack_service_test_user'
+ ctx = create_context(m, self.username, self.tenant)
+ self.stack_name = 'service_test_stack'
cfg.CONF.set_default('heat_stack_user_role', 'stack_user_role')
- stack = get_wordpress_stack(cls.stack_name, ctx)
+ stack = get_wordpress_stack(self.stack_name, ctx)
setup_mocks(m, stack)
m.ReplayAll()
stack.store()
stack.create()
- cls.stack = stack
- cls.stack_identity = stack.identifier()
+ self.stack = stack
+ self.stack_identity = stack.identifier()
m.UnsetStubs()
- @classmethod
- def tearDownClass(cls):
- cls = cls
- m = mox.Mox()
- create_context(m, cls.username, cls.tenant, ctx=cls.stack.context)
- fc = setup_mocks(m, cls.stack)
- m.StubOutWithMock(fc.client, 'get_servers_9999')
- get = fc.client.get_servers_9999
- get().AndRaise(service.clients.novaclient.exceptions.NotFound(404))
- m.ReplayAll()
+ super(stackServiceTestBase, self).setUp()
+ self.m.UnsetStubs()
+ self.ctx = create_context(self.m, self.username, self.tenant)
+ setup_mocks(self.m, self.stack)
- cls.stack.delete()
- m.UnsetStubs()
+class stackServiceTest(stackServiceTestBase):
def setUp(self):
- self.m = mox.Mox()
- setup_dummy_db()
- self.ctx = create_context(self.m, self.username, self.tenant)
- setup_mocks(self.m, self.stack)
+ super(stackServiceTest, self).setUp()
self.m.ReplayAll()
self.man = service.EngineService('a-host', 'a-topic')
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_stack_identify(self):
identity = self.man.identify_stack(self.ctx, self.stack_name)
self.assertEqual(identity, self.stack_identity)
@@ -529,15 +523,6 @@ class stackServiceTest(unittest.TestCase):
self.assertTrue('description' in s)
self.assertNotEqual(s['description'].find('WordPress'), -1)
- def test_stack_list_all_empty(self):
- self.tearDown()
- self.tenant = 'stack_list_all_empty_tenant'
- self.setUp()
-
- sl = self.man.list_stacks(self.ctx)
-
- self.assertEqual(len(sl), 0)
-
def test_stack_describe_nonexistent(self):
nonexist = dict(self.stack_identity)
nonexist['stack_name'] = 'wibble'
@@ -588,15 +573,6 @@ class stackServiceTest(unittest.TestCase):
self.assertNotEqual(s['description'].find('WordPress'), -1)
self.assertTrue('parameters' in s)
- def test_stack_describe_all_empty(self):
- self.tearDown()
- self.tenant = 'stack_describe_all_empty_tenant'
- self.setUp()
-
- sl = self.man.show_stack(self.ctx, None)
-
- self.assertEqual(len(sl), 0)
-
def test_list_resource_types(self):
resources = self.man.list_resource_types(self.ctx)
self.assertTrue(isinstance(resources, list))
@@ -941,3 +917,26 @@ class stackServiceTest(unittest.TestCase):
self.assertRaises(exception.WatchRuleNotFound,
self.man.set_watch_state,
self.ctx, watch_name="nonexistent", state=state)
+
+
+class stackServiceTestEmpty(stackServiceTestBase):
+
+ def setUp(self):
+ super(stackServiceTestEmpty, self).setUp()
+
+ # Change to a new, empty tenant context
+ self.ctx = create_context(self.m, self.username,
+ 'stack_list_all_empty_tenant')
+ self.m.ReplayAll()
+
+ self.man = service.EngineService('a-host', 'a-topic')
+
+ def test_stack_list_all_empty(self):
+ sl = self.man.list_stacks(self.ctx)
+
+ self.assertEqual(len(sl), 0)
+
+ def test_stack_describe_all_empty(self):
+ sl = self.man.show_stack(self.ctx, None)
+
+ self.assertEqual(len(sl), 0)
diff --git a/heat/tests/test_event.py b/heat/tests/test_event.py
index 040883776..3d07b6f6a 100644
--- a/heat/tests/test_event.py
+++ b/heat/tests/test_event.py
@@ -13,10 +13,6 @@
# under the License.
-from nose.plugins.attrib import attr
-import mox
-import unittest
-
from heat.common import context
import heat.db.api as db_api
from heat.engine import parser
@@ -24,6 +20,7 @@ from heat.engine import resource
from heat.engine import template
from heat.engine import event
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
from heat.tests import generic_resource as generic_rsrc
@@ -38,15 +35,12 @@ tmpl = {
}
-@attr(tag=['unit', 'event'])
-@attr(speed='fast')
-class EventTest(unittest.TestCase):
+class EventTest(HeatTestCase):
def setUp(self):
+ super(EventTest, self).setUp()
self.username = 'event_test_user'
- self.m = mox.Mox()
-
setup_dummy_db()
self.ctx = context.get_admin_context()
self.m.StubOutWithMock(self.ctx, 'username')
@@ -70,7 +64,7 @@ class EventTest(unittest.TestCase):
def tearDown(self):
db_api.stack_delete(self.ctx, self.stack.id)
- self.m.UnsetStubs()
+ super(EventTest, self).tearDown()
def test_load(self):
self.resource.resource_id_set('resource_physical_id')
diff --git a/heat/tests/test_identifier.py b/heat/tests/test_identifier.py
index 1f41051f0..f44749e2e 100644
--- a/heat/tests/test_identifier.py
+++ b/heat/tests/test_identifier.py
@@ -14,13 +14,10 @@
import unittest
-from nose.plugins.attrib import attr
from heat.common import identifier
-@attr(tag=['unit', 'identifier'])
-@attr(speed='fast')
class IdentifierTest(unittest.TestCase):
url_prefix = 'http://1.2.3.4/foo/'
@@ -357,8 +354,6 @@ class IdentifierTest(unittest.TestCase):
self.assertEqual(hi._path_components(), ['p1', 'p2', 'p3'])
-@attr(tag=['unit', 'identifier'])
-@attr(speed='fast')
class ResourceIdentifierTest(unittest.TestCase):
def test_resource_init_no_path(self):
si = identifier.HeatIdentifier('t', 's', 'i')
@@ -390,8 +385,6 @@ class ResourceIdentifierTest(unittest.TestCase):
't', 's', 'i', 'p', 'r/r')
-@attr(tag=['unit', 'identifier'])
-@attr(speed='fast')
class EventIdentifierTest(unittest.TestCase):
def test_event_init(self):
si = identifier.HeatIdentifier('t', 's', 'i')
diff --git a/heat/tests/test_instance.py b/heat/tests/test_instance.py
index 25f726ead..004cff1db 100644
--- a/heat/tests/test_instance.py
+++ b/heat/tests/test_instance.py
@@ -16,33 +16,26 @@
import os
import copy
-import unittest
import mox
-from nose.plugins.attrib import attr
-
from heat.tests.v1_1 import fakes
from heat.engine.resources import instance as instances
from heat.common import template_format
from heat.engine import parser
from heat.engine import scheduler
from heat.openstack.common import uuidutils
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource', 'instance'])
-@attr(speed='fast')
-class instancesTest(unittest.TestCase):
+class instancesTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(instancesTest, self).setUp()
self.fc = fakes.FakeClient()
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_instance_create(self):
f = open("%s/WordPress_Single_Instance_gold.template" % self.path)
t = template_format.parse(f.read())
diff --git a/heat/tests/test_instance_group.py b/heat/tests/test_instance_group.py
index e244b0c4e..0d6764b98 100644
--- a/heat/tests/test_instance_group.py
+++ b/heat/tests/test_instance_group.py
@@ -16,11 +16,8 @@ import copy
import os
import eventlet
-import unittest
import mox
-from nose.plugins.attrib import attr
-
from heat.tests.v1_1 import fakes
from heat.common import context
from heat.common import exception
@@ -30,21 +27,17 @@ from heat.engine.resources import instance
from heat.engine.resources import loadbalancer
from heat.engine import parser
from heat.engine import scheduler
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class InstanceGroupTest(unittest.TestCase):
+class InstanceGroupTest(HeatTestCase):
def setUp(self):
+ super(InstanceGroupTest, self).setUp()
self.fc = fakes.FakeClient()
- self.m = mox.Mox()
self.m.StubOutWithMock(loadbalancer.LoadBalancer, 'reload')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def load_template(self):
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
diff --git a/heat/tests/test_loadbalancer.py b/heat/tests/test_loadbalancer.py
index 7ac28b52a..af17b9d26 100644
--- a/heat/tests/test_loadbalancer.py
+++ b/heat/tests/test_loadbalancer.py
@@ -17,8 +17,6 @@ import mox
import re
import os
-from nose.plugins.attrib import attr
-
from oslo.config import cfg
from heat.common import exception
from heat.common import config
@@ -47,8 +45,6 @@ def create_context(mocks, user='lb_test_user',
return ctx
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class LoadBalancerTest(HeatTestCase):
def setUp(self):
super(LoadBalancerTest, self).setUp()
diff --git a/heat/tests/test_loguserdata.py b/heat/tests/test_loguserdata.py
index 94c0f2cb3..3717c2f05 100644
--- a/heat/tests/test_loguserdata.py
+++ b/heat/tests/test_loguserdata.py
@@ -13,17 +13,14 @@
# under the License.
import errno
-import mox
import os
import pkg_resources
import subprocess
-import unittest
import stat
import StringIO
-from nose.plugins.attrib import attr
-
from heat.cloudinit import loguserdata
+from heat.tests.common import HeatTestCase
class FakeCiVersion():
@@ -39,19 +36,14 @@ class FakePOpen():
pass
-@attr(tag=['unit'])
-@attr(speed='fast')
-class LoguserdataTest(unittest.TestCase):
+class LoguserdataTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(LoguserdataTest, self).setUp()
self.m.StubOutWithMock(pkg_resources, 'get_distribution')
self.m.StubOutWithMock(subprocess, 'Popen')
self.m.StubOutWithMock(os, 'chmod')
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_ci_version(self):
# too old versions
pkg_resources.get_distribution('cloud-init').AndReturn(
diff --git a/heat/tests/test_metadata_refresh.py b/heat/tests/test_metadata_refresh.py
index af62d5c68..b1a080e0b 100644
--- a/heat/tests/test_metadata_refresh.py
+++ b/heat/tests/test_metadata_refresh.py
@@ -13,14 +13,12 @@
# under the License.
-import mox
-
import eventlet
-import unittest
-from nose.plugins.attrib import attr
+import mox
from oslo.config import cfg
from heat.tests import fakes
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
from heat.tests.utils import stack_delete_after
@@ -118,23 +116,18 @@ test_template_waitcondition = '''
'''
-@attr(tag=['unit', 'resource', 'Metadata'])
-@attr(speed='slow')
-class MetadataRefreshTest(unittest.TestCase):
+class MetadataRefreshTest(HeatTestCase):
'''
The point of the test is to confirm that metadata gets updated
when FnGetAtt() returns something different.
gets called.
'''
def setUp(self):
- self.m = mox.Mox()
+ super(MetadataRefreshTest, self).setUp()
self.m.StubOutWithMock(eventlet, 'sleep')
self.fc = fakes.FakeKeystoneClient()
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
# Note tests creating a stack should be decorated with @stack_delete_after
# to ensure the stack is properly cleaned up
def create_stack(self, stack_name='test_stack', params={}):
@@ -186,11 +179,9 @@ class MetadataRefreshTest(unittest.TestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'resource', 'Metadata'])
-@attr(speed='slow')
-class WaitCondMetadataUpdateTest(unittest.TestCase):
+class WaitCondMetadataUpdateTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(WaitCondMetadataUpdateTest, self).setUp()
setup_dummy_db()
self.ctx = context.get_admin_context()
self.ctx.tenant_id = 'test_tenant'
@@ -199,9 +190,6 @@ class WaitCondMetadataUpdateTest(unittest.TestCase):
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
- def tearDown(self):
- self.m.UnsetStubs()
-
# Note tests creating a stack should be decorated with @stack_delete_after
# to ensure the stack is properly cleaned up
def create_stack(self, stack_name='test_stack'):
diff --git a/heat/tests/test_nested_stack.py b/heat/tests/test_nested_stack.py
index 4c1db8134..06170f571 100644
--- a/heat/tests/test_nested_stack.py
+++ b/heat/tests/test_nested_stack.py
@@ -13,8 +13,6 @@
# under the License.
-from nose.plugins.attrib import attr
-
from heat.common import context
from heat.common import exception
from heat.common import template_format
@@ -25,8 +23,6 @@ from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class NestedStackTest(HeatTestCase):
test_template = '''
HeatTemplateFormatVersion: '2012-12-12'
diff --git a/heat/tests/test_nokey.py b/heat/tests/test_nokey.py
index 449f7d476..24321939a 100644
--- a/heat/tests/test_nokey.py
+++ b/heat/tests/test_nokey.py
@@ -15,33 +15,24 @@
import os
-import unittest
-import mox
-
-from nose.plugins.attrib import attr
-
from heat.tests.v1_1 import fakes
from heat.engine.resources import instance as instances
from heat.common import template_format
from heat.engine import parser
from heat.engine import scheduler
from heat.openstack.common import uuidutils
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource', 'instance'])
-@attr(speed='fast')
-class nokeyTest(unittest.TestCase):
+class nokeyTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(nokeyTest, self).setUp()
self.fc = fakes.FakeClient()
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_nokey_create(self):
f = open("%s/WordPress_NoKey.template" % self.path)
t = template_format.parse(f.read())
diff --git a/heat/tests/test_parameters.py b/heat/tests/test_parameters.py
index b19831ba8..b9f61e213 100644
--- a/heat/tests/test_parameters.py
+++ b/heat/tests/test_parameters.py
@@ -14,14 +14,11 @@
import unittest
-from nose.plugins.attrib import attr
import json
from heat.engine import parameters
-@attr(tag=['unit', 'parameters'])
-@attr(speed='fast')
class ParameterTest(unittest.TestCase):
def test_new_string(self):
p = parameters.Parameter('p', {'Type': 'String'})
@@ -271,8 +268,6 @@ params_schema = json.loads('''{
}''')
-@attr(tag=['unit', 'parameters'])
-@attr(speed='fast')
class ParametersTest(unittest.TestCase):
def test_pseudo_params(self):
params = parameters.Parameters('test_stack', {"Parameters": {}})
diff --git a/heat/tests/test_parser.py b/heat/tests/test_parser.py
index 0946919c4..1b1d6775f 100644
--- a/heat/tests/test_parser.py
+++ b/heat/tests/test_parser.py
@@ -13,9 +13,6 @@
# under the License.
-import unittest
-from nose.plugins.attrib import attr
-import mox
import uuid
from heat.common import context
@@ -26,6 +23,7 @@ from heat.engine import parser
from heat.engine import parameters
from heat.engine import template
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
from heat.tests.utils import stack_delete_after
from heat.tests import generic_resource as generic_rsrc
@@ -37,9 +35,7 @@ def join(raw):
return parser.Template.resolve_joins(raw)
-@attr(tag=['unit', 'parser'])
-@attr(speed='fast')
-class ParserTest(unittest.TestCase):
+class ParserTest(HeatTestCase):
def test_list(self):
raw = ['foo', 'bar', 'baz']
@@ -115,15 +111,7 @@ mapping_template = template_format.parse('''{
}''')
-@attr(tag=['unit', 'parser', 'template'])
-@attr(speed='fast')
-class TemplateTest(unittest.TestCase):
- def setUp(self):
- self.m = mox.Mox()
-
- def tearDown(self):
- self.m.UnsetStubs()
-
+class TemplateTest(HeatTestCase):
def test_defaults(self):
empty = parser.Template({})
try:
@@ -293,13 +281,11 @@ class TemplateTest(unittest.TestCase):
dict_snippet)
-@attr(tag=['unit', 'parser', 'stack'])
-@attr(speed='fast')
-class StackTest(unittest.TestCase):
+class StackTest(HeatTestCase):
def setUp(self):
- self.username = 'parser_stack_test_user'
+ super(StackTest, self).setUp()
- self.m = mox.Mox()
+ self.username = 'parser_stack_test_user'
setup_dummy_db()
self.ctx = context.get_admin_context()
@@ -313,9 +299,6 @@ class StackTest(unittest.TestCase):
self.m.ReplayAll()
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_state_defaults(self):
stack = parser.Stack(None, 'test_stack', parser.Template({}))
self.assertEqual(stack.state, None)
diff --git a/heat/tests/test_plugin_loader.py b/heat/tests/test_plugin_loader.py
index 96dd4a305..c72ddd887 100644
--- a/heat/tests/test_plugin_loader.py
+++ b/heat/tests/test_plugin_loader.py
@@ -16,14 +16,11 @@
import pkgutil
import sys
import unittest
-from nose.plugins.attrib import attr
import heat.engine
from heat.common import plugin_loader
-@attr(tag=['unit', 'plugin_loader'])
-@attr(speed='fast')
class PluginLoaderTest(unittest.TestCase):
def test_module_name(self):
self.assertEqual(plugin_loader._module_name('foo.bar', 'blarg.wibble'),
diff --git a/heat/tests/test_properties.py b/heat/tests/test_properties.py
index 2afd1d23d..28dc4d1d9 100644
--- a/heat/tests/test_properties.py
+++ b/heat/tests/test_properties.py
@@ -14,14 +14,11 @@
import unittest
-from nose.plugins.attrib import attr
from heat.engine import properties
from heat.common import exception
-@attr(tag=['unit', 'properties'])
-@attr(speed='fast')
class PropertyTest(unittest.TestCase):
def test_required_default(self):
p = properties.Property({'Type': 'String'})
@@ -259,8 +256,6 @@ class PropertyTest(unittest.TestCase):
self.assertRaises(TypeError, p.validate_data, [42, 'fish'])
-@attr(tag=['unit', 'properties'])
-@attr(speed='fast')
class PropertiesTest(unittest.TestCase):
def setUp(self):
schema = {
@@ -306,8 +301,6 @@ class PropertiesTest(unittest.TestCase):
self.assertEqual(self.props.get('foo', 'wibble'), 'wibble')
-@attr(tag=['unit', 'properties'])
-@attr(speed='fast')
class PropertiesValidationTest(unittest.TestCase):
def test_required(self):
schema = {'foo': {'Type': 'String', 'Required': True}}
diff --git a/heat/tests/test_quantum.py b/heat/tests/test_quantum.py
index 5b360cfd0..694e17184 100644
--- a/heat/tests/test_quantum.py
+++ b/heat/tests/test_quantum.py
@@ -15,11 +15,7 @@
import os
-import unittest
-import mox
-
-from nose.plugins.attrib import attr
-from nose.exc import SkipTest
+from testtools import skipIf
from heat.common import context
from heat.common import exception
@@ -31,6 +27,7 @@ from heat.engine.resources.quantum import floatingip
from heat.engine.resources.quantum import port
from heat.engine.resources.quantum.quantum import QuantumResource as qr
from heat.engine import parser
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
@@ -98,17 +95,12 @@ class FakeQuantum():
}}
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class QuantumTest(unittest.TestCase):
+class QuantumTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(QuantumTest, self).setUp()
self.m.StubOutWithMock(net.Net, 'quantum')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def load_template(self):
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
@@ -172,8 +164,7 @@ class QuantumTest(unittest.TestCase):
'admin_state_up': False}, props)
def test_net(self):
- if net.clients.quantumclient is None:
- raise SkipTest
+ skipIf(net.clients.quantumclient is None, 'quantumclient unavailable')
fq = FakeQuantum()
net.Net.quantum().MultipleTimes().AndReturn(fq)
@@ -204,19 +195,14 @@ class QuantumTest(unittest.TestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class QuantumFloatingIPTest(unittest.TestCase):
+class QuantumFloatingIPTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(QuantumFloatingIPTest, self).setUp()
self.m.StubOutWithMock(floatingip.FloatingIP, 'quantum')
self.m.StubOutWithMock(floatingip.FloatingIPAssociation, 'quantum')
self.m.StubOutWithMock(port.Port, 'quantum')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def load_template(self, name='Quantum'):
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py
index 19e7b17d6..5bb7af125 100644
--- a/heat/tests/test_resource.py
+++ b/heat/tests/test_resource.py
@@ -13,10 +13,6 @@
# under the License.
-import unittest
-from nose.plugins.attrib import attr
-import mox
-
from heat.common import context
from heat.common import exception
from heat.engine import parser
@@ -25,14 +21,13 @@ from heat.engine import scheduler
from heat.openstack.common import uuidutils
from heat.tests import generic_resource as generic_rsrc
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class ResourceTest(unittest.TestCase):
+class ResourceTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(ResourceTest, self).setUp()
setup_dummy_db()
self.stack = parser.Stack(None, 'test_stack', parser.Template({}),
stack_id=uuidutils.generate_uuid())
@@ -40,9 +35,6 @@ class ResourceTest(unittest.TestCase):
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_get_class_ok(self):
cls = resource.get_class('GenericResourceType')
self.assertEqual(cls, generic_rsrc.GenericResource)
@@ -315,11 +307,9 @@ class ResourceTest(unittest.TestCase):
self.assertEqual(res.UPDATE_FAILED, res.state)
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class MetadataTest(unittest.TestCase):
+class MetadataTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(MetadataTest, self).setUp()
tmpl = {
'Type': 'Foo',
'Metadata': {'Test': 'Initial metadata'}
@@ -336,7 +326,7 @@ class MetadataTest(unittest.TestCase):
def tearDown(self):
self.stack.delete()
- self.m.UnsetStubs()
+ super(HeatTestCase, self).tearDown()
def test_read_initial(self):
self.assertEqual(self.res.metadata, {'Test': 'Initial metadata'})
diff --git a/heat/tests/test_rpc_client.py b/heat/tests/test_rpc_client.py
index 7783d225a..7e6948901 100644
--- a/heat/tests/test_rpc_client.py
+++ b/heat/tests/test_rpc_client.py
@@ -19,7 +19,6 @@ Unit Tests for heat.rpc.client
"""
-from nose.plugins.attrib import attr
from oslo.config import cfg
import stubout
import unittest
@@ -32,7 +31,6 @@ from heat.rpc import client as rpc_client
from heat.openstack.common import rpc
-@attr(tag=['unit', 'rpcapi'])
class EngineRpcAPITestCase(unittest.TestCase):
def setUp(self):
@@ -49,9 +47,6 @@ class EngineRpcAPITestCase(unittest.TestCase):
'wordpress'))
super(EngineRpcAPITestCase, self).setUp()
- def tearDown(self):
- super(EngineRpcAPITestCase, self).tearDown()
-
def _test_engine_api(self, method, rpc_method, **kwargs):
ctxt = context.RequestContext('fake_user', 'fake_project')
if 'rpcapi_class' in kwargs:
diff --git a/heat/tests/test_s3.py b/heat/tests/test_s3.py
index 95cb60c7c..de4cc5ca0 100644
--- a/heat/tests/test_s3.py
+++ b/heat/tests/test_s3.py
@@ -16,29 +16,25 @@
import os
import re
-import unittest
import mox
-from nose.plugins.attrib import attr
-
from heat.common import context
from heat.common import template_format
from heat.openstack.common.importutils import try_import
from heat.engine.resources import s3
from heat.engine import parser
from heat.engine import scheduler
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
from heat.tests.utils import skip_if
swiftclient = try_import('swiftclient.client')
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class s3Test(unittest.TestCase):
+class s3Test(HeatTestCase):
@skip_if(swiftclient is None, 'unable to import swiftclient')
def setUp(self):
- self.m = mox.Mox()
+ super(s3Test, self).setUp()
self.m.CreateMock(swiftclient.Connection)
self.m.StubOutWithMock(swiftclient.Connection, 'put_container')
self.m.StubOutWithMock(swiftclient.Connection, 'delete_container')
@@ -47,9 +43,6 @@ class s3Test(unittest.TestCase):
self.container_pattern = 'test_stack-test_resource-[0-9a-z]+'
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def load_template(self):
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
diff --git a/heat/tests/test_security_group.py b/heat/tests/test_security_group.py
index 3d17f78c9..913248cde 100644
--- a/heat/tests/test_security_group.py
+++ b/heat/tests/test_security_group.py
@@ -13,15 +13,12 @@
# under the License.
import collections
-import unittest
-import mox
-
-from nose.plugins.attrib import attr
from heat.engine import clients
from heat.common import context
from heat.common import template_format
from heat.engine import parser
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
from heat.tests.v1_1 import fakes
@@ -37,9 +34,7 @@ NovaSG = collections.namedtuple('NovaSG',
]))
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class SecurityGroupTest(unittest.TestCase):
+class SecurityGroupTest(HeatTestCase):
test_template_nova = '''
HeatTemplateFormatVersion: '2012-12-12'
@@ -60,7 +55,7 @@ Resources:
'''
def setUp(self):
- self.m = mox.Mox()
+ super(SecurityGroupTest, self).setUp()
self.fc = fakes.FakeClient()
self.m.StubOutWithMock(clients.OpenStackClients, 'nova')
self.m.StubOutWithMock(nova_sgr.SecurityGroupRuleManager, 'create')
@@ -71,9 +66,6 @@ Resources:
self.m.StubOutWithMock(nova_sg.SecurityGroupManager, 'list')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def create_stack(self, template):
t = template_format.parse(template)
stack = self.parse_stack(t)
diff --git a/heat/tests/test_short_id.py b/heat/tests/test_short_id.py
index ee3994852..fe48309e3 100644
--- a/heat/tests/test_short_id.py
+++ b/heat/tests/test_short_id.py
@@ -14,14 +14,11 @@
import unittest
-from nose.plugins.attrib import attr
from heat.common import short_id
import uuid
-@attr(tag=['unit', 'short_id'])
-@attr(speed='fast')
class ShortIdTest(unittest.TestCase):
def test_byte_string_8(self):
diff --git a/heat/tests/test_swift.py b/heat/tests/test_swift.py
index 472ba2a22..787a9aabd 100644
--- a/heat/tests/test_swift.py
+++ b/heat/tests/test_swift.py
@@ -16,29 +16,25 @@
import os
import re
-import unittest
import mox
-from nose.plugins.attrib import attr
-
from heat.common import context
from heat.common import template_format
from heat.openstack.common.importutils import try_import
from heat.engine.resources import swift
from heat.engine import parser
from heat.engine import scheduler
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
from heat.tests.utils import skip_if
swiftclient = try_import('swiftclient.client')
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
-class swiftTest(unittest.TestCase):
+class swiftTest(HeatTestCase):
@skip_if(swiftclient is None, 'unable to import swiftclient')
def setUp(self):
- self.m = mox.Mox()
+ super(swiftTest, self).setUp()
self.m.CreateMock(swiftclient.Connection)
self.m.StubOutWithMock(swiftclient.Connection, 'put_container')
self.m.StubOutWithMock(swiftclient.Connection, 'delete_container')
@@ -48,9 +44,6 @@ class swiftTest(unittest.TestCase):
self.container_pattern = 'test_stack-test_resource-[0-9a-z]+'
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def load_template(self):
self.path = os.path.dirname(os.path.realpath(__file__)).\
replace('heat/tests', 'templates')
diff --git a/heat/tests/test_template_format.py b/heat/tests/test_template_format.py
index 6c0e28c71..ac274731f 100644
--- a/heat/tests/test_template_format.py
+++ b/heat/tests/test_template_format.py
@@ -12,8 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
-from nose.plugins.attrib import attr
-from nose.exc import SkipTest
+from testtools import skipIf
import os
import unittest
@@ -24,7 +23,6 @@ from heat.engine import parser
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit'])
class JsonToYamlTest(unittest.TestCase):
def setUp(self):
@@ -78,7 +76,6 @@ class JsonToYamlTest(unittest.TestCase):
yield (json_str, yml_str, f.name)
-@attr(tag=['unit'])
class YamlMinimalTest(unittest.TestCase):
def test_minimal_yaml(self):
@@ -94,7 +91,6 @@ Outputs: {}
self.assertEqual(tpl1, tpl2)
-@attr(tag=['unit'])
class JsonYamlResolvedCompareTest(unittest.TestCase):
def setUp(self):
@@ -150,8 +146,7 @@ class JsonYamlResolvedCompareTest(unittest.TestCase):
self.assertEqual(stack1.resources[key].t, stack2.resources[key].t)
def test_quantum_resolved(self):
- if clients.quantumclient is None:
- raise SkipTest
+ skipIf(clients.quantumclient is None, 'quantumclient unavailable')
self.compare_stacks('Quantum.template', 'Quantum.yaml', {})
def test_wordpress_resolved(self):
diff --git a/heat/tests/test_urlfetch.py b/heat/tests/test_urlfetch.py
index c0ab8c7cf..7d794ef8f 100644
--- a/heat/tests/test_urlfetch.py
+++ b/heat/tests/test_urlfetch.py
@@ -13,25 +13,18 @@
# License for the specific language governing permissions and limitations
# under the License.
-import mox
-from nose.plugins.attrib import attr
import StringIO
-import unittest
import urllib2
from heat.common import urlfetch
+from heat.tests.common import HeatTestCase
-@attr(tag=['unit', 'urlfetch'])
-@attr(speed='fast')
-class UrlFetchTest(unittest.TestCase):
+class UrlFetchTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(UrlFetchTest, self).setUp()
self.m.StubOutWithMock(urllib2, 'urlopen')
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_file_scheme(self):
self.m.ReplayAll()
self.assertRaises(IOError, urlfetch.get, 'file:///etc/profile')
diff --git a/heat/tests/test_user.py b/heat/tests/test_user.py
index bfc757d04..4656da75d 100644
--- a/heat/tests/test_user.py
+++ b/heat/tests/test_user.py
@@ -14,10 +14,7 @@
import os
-import unittest
-import mox
-from nose.plugins.attrib import attr
from oslo.config import cfg
from heat.common import config
@@ -27,26 +24,22 @@ from heat.common import template_format
from heat.engine import parser
from heat.engine import scheduler
from heat.engine.resources import user
+from heat.tests.common import HeatTestCase
from heat.tests import fakes
from heat.tests.utils import setup_dummy_db
import keystoneclient.exceptions
-class UserPolicyTestCase(unittest.TestCase):
+class UserPolicyTestCase(HeatTestCase):
def setUp(self):
+ super(UserPolicyTestCase, self).setUp()
config.register_engine_opts()
- self.m = mox.Mox()
self.fc = fakes.FakeKeystoneClient(username='test_stack.CfnUser')
cfg.CONF.set_default('heat_stack_user_role', 'stack_user_role')
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
-@attr(tag=['unit', 'resource', 'User'])
-@attr(speed='fast')
class UserTest(UserPolicyTestCase):
def load_template(self, template_name='Rails_Single_Instance.template'):
@@ -228,8 +221,6 @@ class UserTest(UserPolicyTestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'resource', 'AccessKey'])
-@attr(speed='fast')
class AccessKeyTest(UserPolicyTestCase):
def load_template(self):
@@ -338,8 +329,6 @@ class AccessKeyTest(UserPolicyTestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'resource', 'AccessPolicy'])
-@attr(speed='fast')
class AccessPolicyTest(UserPolicyTestCase):
def load_template(self):
diff --git a/heat/tests/test_validate.py b/heat/tests/test_validate.py
index 70ee035f2..808d5ed5e 100644
--- a/heat/tests/test_validate.py
+++ b/heat/tests/test_validate.py
@@ -13,11 +13,6 @@
# under the License.
-import unittest
-import mox
-
-from nose.plugins.attrib import attr
-
from heat.tests.v1_1 import fakes
from heat.common import exception
from heat.common import template_format
@@ -25,6 +20,7 @@ from heat.engine.resources import instance as instances
from heat.engine import service
import heat.db.api as db_api
from heat.engine import parser
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
test_template_volumeattach = '''
@@ -267,17 +263,12 @@ test_template_unimplemented_property = '''
'''
-@attr(tag=['unit', 'validate'])
-@attr(speed='fast')
-class validateTest(unittest.TestCase):
+class validateTest(HeatTestCase):
def setUp(self):
- self.m = mox.Mox()
+ super(validateTest, self).setUp()
self.fc = fakes.FakeClient()
setup_dummy_db()
- def tearDown(self):
- self.m.UnsetStubs()
-
def test_validate_volumeattach_valid(self):
t = template_format.parse(test_template_volumeattach % 'vdq')
stack = parser.Stack(None, 'test_stack', parser.Template(t))
diff --git a/heat/tests/test_volume.py b/heat/tests/test_volume.py
index 7fb133f8a..ef6cde43f 100644
--- a/heat/tests/test_volume.py
+++ b/heat/tests/test_volume.py
@@ -17,8 +17,6 @@ import os
import eventlet
-from nose.plugins.attrib import attr
-
from heat.common import context
from heat.common import exception
from heat.common import template_format
@@ -31,8 +29,6 @@ from heat.tests.v1_1 import fakes
from heat.tests.utils import setup_dummy_db
-@attr(tag=['unit', 'resource', 'volume'])
-@attr(speed='fast')
class VolumeTest(HeatTestCase):
def setUp(self):
super(VolumeTest, self).setUp()
diff --git a/heat/tests/test_vpc.py b/heat/tests/test_vpc.py
index c27f18524..c863634a7 100644
--- a/heat/tests/test_vpc.py
+++ b/heat/tests/test_vpc.py
@@ -12,31 +12,28 @@
# License for the specific language governing permissions and limitations
# under the License.
-
-import unittest
-import mox
-
-from nose.plugins.attrib import attr
+from testtools import skipIf
from heat.common import context
from heat.common import exception
from heat.common import template_format
from heat.engine import parser
+from heat.tests.common import HeatTestCase
from heat.tests.utils import setup_dummy_db
try:
from quantumclient.common.exceptions import QuantumClientException
from quantumclient.v2_0 import client as quantumclient
except ImportError:
- from nose.exc import SkipTest
- raise SkipTest()
+ quantumclient = None
-class VPCTestBase(unittest.TestCase):
+class VPCTestBase(HeatTestCase):
def setUp(self):
+ super(VPCTestBase, self).setUp()
+ skipIf(quantumclient is None, 'quantumclient unavaialble')
setup_dummy_db()
- self.m = mox.Mox()
self.m.StubOutWithMock(quantumclient.Client, 'add_interface_router')
self.m.StubOutWithMock(quantumclient.Client, 'add_gateway_router')
self.m.StubOutWithMock(quantumclient.Client, 'create_network')
@@ -53,9 +50,6 @@ class VPCTestBase(unittest.TestCase):
self.m.StubOutWithMock(quantumclient.Client, 'show_subnet')
self.m.StubOutWithMock(quantumclient.Client, 'show_network')
- def tearDown(self):
- self.m.UnsetStubs()
-
def create_stack(self, template):
t = template_format.parse(template)
stack = self.parse_stack(t)
@@ -131,8 +125,6 @@ class VPCTestBase(unittest.TestCase):
self.assertEqual(metadata, dict(resource.metadata))
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class VPCTest(VPCTestBase):
test_template = '''
@@ -159,8 +151,6 @@ Resources:
self.m.VerifyAll()
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class SubnetTest(VPCTestBase):
test_template = '''
@@ -214,8 +204,6 @@ Resources:
self.m.VerifyAll()
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class NetworkInterfaceTest(VPCTestBase):
test_template = '''
@@ -289,8 +277,6 @@ Resources:
self.m.VerifyAll()
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class InternetGatewayTest(VPCTestBase):
test_template = '''
@@ -363,8 +349,6 @@ Resources:
self.m.VerifyAll()
-@attr(tag=['unit', 'resource'])
-@attr(speed='fast')
class RouteTableTest(VPCTestBase):
test_template = '''
diff --git a/heat/tests/test_waitcondition.py b/heat/tests/test_waitcondition.py
index a006e40d2..b6024dff7 100644
--- a/heat/tests/test_waitcondition.py
+++ b/heat/tests/test_waitcondition.py
@@ -13,16 +13,14 @@
# under the License.
-import mox
import uuid
import datetime
import json
import eventlet
-from nose.plugins.attrib import attr
from oslo.config import cfg
-import unittest
+from heat.tests.common import HeatTestCase
from heat.tests import fakes
from heat.tests.utils import stack_delete_after
from heat.tests.utils import setup_dummy_db
@@ -77,14 +75,12 @@ test_template_wc_count = '''
'''
-@attr(tag=['unit', 'resource', 'WaitCondition'])
-@attr(speed='slow')
-class WaitConditionTest(unittest.TestCase):
+class WaitConditionTest(HeatTestCase):
def setUp(self):
+ super(WaitConditionTest, self).setUp()
config.register_engine_opts()
setup_dummy_db()
- self.m = mox.Mox()
self.m.StubOutWithMock(wc.WaitConditionHandle,
'get_status')
self.m.StubOutWithMock(wc.WaitCondition,
@@ -96,9 +92,6 @@ class WaitConditionTest(unittest.TestCase):
self.fc = fakes.FakeKeystoneClient()
- def tearDown(self):
- self.m.UnsetStubs()
-
# Note tests creating a stack should be decorated with @stack_delete_after
# to ensure the stack is properly cleaned up
def create_stack(self, stack_name='test_stack',
@@ -382,12 +375,10 @@ class WaitConditionTest(unittest.TestCase):
self.m.VerifyAll()
-@attr(tag=['unit', 'resource', 'WaitConditionHandle'])
-@attr(speed='fast')
-class WaitConditionHandleTest(unittest.TestCase):
+class WaitConditionHandleTest(HeatTestCase):
def setUp(self):
+ super(WaitConditionHandleTest, self).setUp()
config.register_engine_opts()
- self.m = mox.Mox()
cfg.CONF.set_default('heat_waitcondition_server_url',
'http://127.0.0.1:8000/v1/waitcondition')
@@ -395,9 +386,6 @@ class WaitConditionHandleTest(unittest.TestCase):
setup_dummy_db()
self.stack = self.create_stack()
- def tearDown(self):
- self.m.UnsetStubs()
-
def create_stack(self, stack_name='test_stack2', params={}):
temp = template_format.parse(test_template_waitcondition)
template = parser.Template(temp)
diff --git a/heat/tests/test_watch.py b/heat/tests/test_watch.py
index 1e134c1af..d8dd0d7c3 100644
--- a/heat/tests/test_watch.py
+++ b/heat/tests/test_watch.py
@@ -15,14 +15,13 @@
import datetime
import mox
-from nose.plugins.attrib import attr
-import unittest
from heat.common import context
import heat.db.api as db_api
from heat.openstack.common import timeutils
from heat.engine import watchrule
from heat.engine import parser
+from heat.tests.common import HeatTestCase
from heat.tests import utils
@@ -37,9 +36,7 @@ class DummyAction:
alarm = "DummyAction"
-@attr(tag=['unit', 'watchrule'])
-@attr(speed='fast')
-class WatchRuleTest(unittest.TestCase):
+class WatchRuleTest(HeatTestCase):
@classmethod
def setUpClass(cls):
@@ -60,19 +57,15 @@ class WatchRuleTest(unittest.TestCase):
cls.stack_id = dummy_stack.id
def setUp(self):
+ super(WatchRuleTest, self).setUp()
self.username = 'watchrule_test_user'
- self.m = mox.Mox()
-
self.ctx = context.get_admin_context()
self.ctx.username = self.username
self.ctx.tenant_id = u'123456'
self.m.ReplayAll()
- def tearDown(self):
- self.m.UnsetStubs()
-
def _action_set_stubs(self, now, action_expected=True):
# Setup stubs for the action tests
self.m.StubOutWithMock(timeutils, 'utcnow')