]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Remove use of nose attrib plugin and most unittest
authorClint Byrum <clint@fewbar.com>
Fri, 26 Apr 2013 22:49:33 +0000 (15:49 -0700)
committerClint Byrum <clint@fewbar.com>
Tue, 30 Apr 2013 20:51:31 +0000 (13:51 -0700)
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

40 files changed:
heat/tests/test_api_aws.py
heat/tests/test_api_cfn_v1.py
heat/tests/test_api_cloudwatch.py
heat/tests/test_api_openstack_v1.py
heat/tests/test_autoscaling.py
heat/tests/test_cli.py
heat/tests/test_common_policy.py
heat/tests/test_dbinstance.py
heat/tests/test_dependencies.py
heat/tests/test_eip.py
heat/tests/test_engine_api_utils.py
heat/tests/test_engine_service.py
heat/tests/test_event.py
heat/tests/test_identifier.py
heat/tests/test_instance.py
heat/tests/test_instance_group.py
heat/tests/test_loadbalancer.py
heat/tests/test_loguserdata.py
heat/tests/test_metadata_refresh.py
heat/tests/test_nested_stack.py
heat/tests/test_nokey.py
heat/tests/test_parameters.py
heat/tests/test_parser.py
heat/tests/test_plugin_loader.py
heat/tests/test_properties.py
heat/tests/test_quantum.py
heat/tests/test_resource.py
heat/tests/test_rpc_client.py
heat/tests/test_s3.py
heat/tests/test_security_group.py
heat/tests/test_short_id.py
heat/tests/test_swift.py
heat/tests/test_template_format.py
heat/tests/test_urlfetch.py
heat/tests/test_user.py
heat/tests/test_validate.py
heat/tests/test_volume.py
heat/tests/test_vpc.py
heat/tests/test_waitcondition.py
heat/tests/test_watch.py

index a54a5eb677b77bb84a2710a01345a129e02de337..093d655ba12fe05cdbfd97a99b906bc87f33806f 100644 (file)
 
 
 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
index a13363f9595f1ed13a8d13ea282c1db983bf0802..6ec9c4a8c447206bc30f6dfef080b814cac2d8b0 100644 (file)
@@ -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,
index ed189c68a8f74c7fe2866b84013cafae49c2bdf8..82c46e90e9bc72daa32259565a9dac94d7278942 100644 (file)
@@ -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,
index 76909000ac4b79e1d39de1d8bca914f1f7e8fe14..39946fdd63a9758bd3cb32e390431cdb19d736aa 100644 (file)
 #    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):
index de28c6edd109fa2420f3dedb4df271de482c2802..a1b937f39d4ac2a6910f560552dfad89b200f11d 100644 (file)
@@ -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')
index 753b90e2638e99fd07a5b686880141f587021f91..934bfdf588f82d510604670f4dc132cdd6fd9cf2 100644 (file)
@@ -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):
index af8bb0534d63ac1bc69f66b64ff141bd007e118b..66a7c33634322df0b93903db2c58b37e70e1fd42 100644 (file)
 
 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')
 
index dfea6007560897f050374475ed791aa821a4117f..2d815fbcf34e2e7fbb9dcdc5cb258709d0c20cf5 100644 (file)
@@ -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()
index 36a19126191e798dddc8760b82d7a66952597908..ec2f546e1c38860427bded5e6b990fe00044a248 100644 (file)
 
 
 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):
index 9007d34436eba3aa097a8ba857f4757f9e05728d..5aa01d20ef7a4ae79e3a7344e9500b1772295a83 100644 (file)
 
 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')
index 801748f8a367372edcf5a68b5dd71904f233bdee..f9305b2ebb8f64a390fb3b93f4cec267af2a7cb3 100644 (file)
 
 
 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'}
index cd2d473ff9f2114d21458e2eaff33ad9c67e7e46..de2655577dcb42b8511bf39abfdf5c63e006ce74 100644 (file)
 
 
 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)
index 04088377688d5b132c3fec9bea19e832313a3a29..3d07b6f6a39526ffe4b118ad29a28f849f5fa034 100644 (file)
 #    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')
index 1f41051f06d7e2023373e44f3c6bcbf72885bc0e..f44749e2ee770447db89299eed34bee7993e7b2f 100644 (file)
 
 
 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')
index 25f726ead039e7a691bb24ada888bd5c97ca46c0..004cff1db1286d78e62aca538d2e3f6ec2837aa2 100644 (file)
 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())
index e244b0c4ebc5eeca56db5db10b1356a41474cd2b..0d6764b98fb7d3620e755b7191272b8efde3a802 100644 (file)
@@ -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')
index 7ac28b52a3229c23b3a3e3cd0199459f88d1028a..af17b9d266768bc929f3fc50e0a57b5f49257487 100644 (file)
@@ -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()
index 94c0f2cb36d5b30ab798138269babdcd0946e3b5..3717c2f054b5a9a17a4610e5653fb7ab416393fc 100644 (file)
 #    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(
index af62d5c680e71f98280112eea4417d673f1e86d4..b1a080e0bad04850d228a761cd12c72f97f2f491 100644 (file)
 #    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'):
index 4c1db81343138050cb300f817a46ff3ce3f8ca79..06170f57180724e33053d86a66254a20c2392e56 100644 (file)
@@ -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'
index 449f7d476c1c0ce7da344f27719263ea94c69a6d..24321939a2cb752fa749729fea23bb5bb4345174 100644 (file)
 
 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())
index b19831ba88fce919c4ad2944007fd6d769b177e5..b9f61e213774e5d5b8837b82220ae58515cf88c6 100644 (file)
 
 
 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": {}})
index 0946919c467ce0cf6b32b0c81260f0315b7e98f8..1b1d6775f5cecf8b9a035c7700eaf346dc120395 100644 (file)
@@ -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)
index 96dd4a305a41ff12f49a077b7f689af80c43d7a7..c72ddd8872a473c5893dfdb88b1c93a1527856dd 100644 (file)
 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'),
index 2afd1d23d288892f740ddb09a5be54b8ea8bcdee..28dc4d1d9f9433ed4670da527cc612232a72fbe4 100644 (file)
 
 
 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}}
index 5b360cfd03aa16c1e23e363294bb5e6b85ab25f6..694e17184bae70c8554ed0bd34b474c455c819f8 100644 (file)
 
 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')
index 19e7b17d6f0ce49b1f14a933fca33667e11a441c..5bb7af125ef5113b57af32993043961751995759 100644 (file)
 #    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'})
index 7783d225a471ca2ffd84189fb7865358a618575f..7e69489019f7a267f04f4351d8e3e7fd43bd49cf 100644 (file)
@@ -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:
index 95cb60c7caf8a2d2395c35668cd4d57eb7bab7a8..de4cc5ca09f21bd0a115fc76637d97671053a43c 100644 (file)
 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')
index 3d17f78c90356958ec3282d46df00a962f69f5b5..913248cde188230f9b53c479e026ded2f2d9871d 100644 (file)
 #    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)
index ee3994852589981c013fa9dd59354e590db2bb97..fe48309e3262fb422b40c35d601d1c3fb67ef00b 100644 (file)
 
 
 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):
index 472ba2a2241e50d97c3664429a38ef80a93680e3..787a9aabd9ea61ce07cc536da5d5ff984e4832dc 100644 (file)
 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')
index 6c0e28c711ec0945553f608a637f40f6bde517f7..ac274731f5965c95a3f52c7f606150cd7571513a 100644 (file)
@@ -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):
index c0ab8c7cf5e8b5a2708bb14a400d0d257c44d59e..7d794ef8ffcf8acf99ab0e4d23566c45827dc9a6 100644 (file)
 #    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')
index bfc757d04dca38506db36dd91bdc5f3f06276fd5..4656da75df8de5cc08d6135b053cd7600da4f0b5 100644 (file)
 
 
 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):
index 70ee035f22656b12213d85f939e91ee768055122..808d5ed5ec2e852b1949efd6bfab19ce6293abfb 100644 (file)
 #    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))
index 7fb133f8a105cd4ce3dc52741ffae6f0e30676cb..ef6cde43fc1896969829683d7ef4f0dfd47cad15 100644 (file)
@@ -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()
index c27f18524f64d4be705565cb0184d7d46997e355..c863634a7c2658bba6be0f5aea2232645fbf81d9 100644 (file)
 #    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 = '''
index a006e40d2afa30e2159d37a8d3097cc89c8981af..b6024dff76d820973d14a95fabcded6bd907efe9 100644 (file)
 #    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)
index 1e134c1af8f8cc49f131c31c245141bb7f774ef4..d8dd0d7c3ae3003e85ac86d89c422a34d37e5804 100644 (file)
 
 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')