Migrate test base class to testtools.
This is stricter, but also provides plumbing for more advanced things like fixtures and testscenarios. Change-Id: I607b50390708ca3caa9799ef0b27007df5045a6c
This commit is contained in:
parent
04d37a7ae6
commit
77afc90b5d
|
@ -86,9 +86,9 @@ Example::
|
||||||
import random
|
import random
|
||||||
import StringIO
|
import StringIO
|
||||||
import time
|
import time
|
||||||
import unittest
|
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
import testtools
|
||||||
import webob.exc
|
import webob.exc
|
||||||
|
|
||||||
import heat.api.ec2
|
import heat.api.ec2
|
||||||
|
|
|
@ -524,7 +524,4 @@ class WatchControllerTest(HeatTestCase):
|
||||||
cfgopts = DummyConfig()
|
cfgopts = DummyConfig()
|
||||||
self.controller = watches.WatchController(options=cfgopts)
|
self.controller = watches.WatchController(options=cfgopts)
|
||||||
self.controller.policy.policy_path = None
|
self.controller.policy.policy_path = None
|
||||||
|
self.addCleanup(self.m.VerifyAll)
|
||||||
def tearDown(self):
|
|
||||||
self.m.VerifyAll()
|
|
||||||
super(WatchControllerTest, self).tearDown()
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import testtools
|
||||||
import heat
|
import heat
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -21,7 +21,7 @@ import subprocess
|
||||||
basepath = os.path.join(heat.__path__[0], os.path.pardir)
|
basepath = os.path.join(heat.__path__[0], os.path.pardir)
|
||||||
|
|
||||||
|
|
||||||
class CliTest(unittest.TestCase):
|
class CliTest(testtools.TestCase):
|
||||||
|
|
||||||
def test_heat_cfn(self):
|
def test_heat_cfn(self):
|
||||||
self.bin_test_run('heat-cfn')
|
self.bin_test_run('heat-cfn')
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import testtools
|
||||||
|
|
||||||
from heat.engine.dependencies import Dependencies
|
from heat.engine.dependencies import Dependencies
|
||||||
from heat.engine.dependencies import CircularDependencyException
|
from heat.engine.dependencies import CircularDependencyException
|
||||||
|
|
||||||
|
|
||||||
class dependenciesTest(unittest.TestCase):
|
class dependenciesTest(testtools.TestCase):
|
||||||
|
|
||||||
def _dep_test(self, func, checkorder, deps):
|
def _dep_test(self, func, checkorder, deps):
|
||||||
nodes = set.union(*[set(e) for e in deps])
|
nodes = set.union(*[set(e) for e in deps])
|
||||||
|
|
|
@ -61,10 +61,7 @@ class EventTest(HeatTestCase):
|
||||||
|
|
||||||
self.resource = self.stack['EventTestResource']
|
self.resource = self.stack['EventTestResource']
|
||||||
self.resource._store()
|
self.resource._store()
|
||||||
|
self.addCleanup(db_api.stack_delete, self.ctx, self.stack.id)
|
||||||
def tearDown(self):
|
|
||||||
db_api.stack_delete(self.ctx, self.stack.id)
|
|
||||||
super(EventTest, self).tearDown()
|
|
||||||
|
|
||||||
def test_load(self):
|
def test_load(self):
|
||||||
self.resource.resource_id_set('resource_physical_id')
|
self.resource.resource_id_set('resource_physical_id')
|
||||||
|
|
|
@ -13,12 +13,12 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import testtools
|
||||||
|
|
||||||
from heat.common import identifier
|
from heat.common import identifier
|
||||||
|
|
||||||
|
|
||||||
class IdentifierTest(unittest.TestCase):
|
class IdentifierTest(testtools.TestCase):
|
||||||
url_prefix = 'http://1.2.3.4/foo/'
|
url_prefix = 'http://1.2.3.4/foo/'
|
||||||
|
|
||||||
def test_attrs(self):
|
def test_attrs(self):
|
||||||
|
@ -354,7 +354,7 @@ class IdentifierTest(unittest.TestCase):
|
||||||
self.assertEqual(hi._path_components(), ['p1', 'p2', 'p3'])
|
self.assertEqual(hi._path_components(), ['p1', 'p2', 'p3'])
|
||||||
|
|
||||||
|
|
||||||
class ResourceIdentifierTest(unittest.TestCase):
|
class ResourceIdentifierTest(testtools.TestCase):
|
||||||
def test_resource_init_no_path(self):
|
def test_resource_init_no_path(self):
|
||||||
si = identifier.HeatIdentifier('t', 's', 'i')
|
si = identifier.HeatIdentifier('t', 's', 'i')
|
||||||
ri = identifier.ResourceIdentifier(resource_name='r', **si)
|
ri = identifier.ResourceIdentifier(resource_name='r', **si)
|
||||||
|
@ -385,7 +385,7 @@ class ResourceIdentifierTest(unittest.TestCase):
|
||||||
't', 's', 'i', 'p', 'r/r')
|
't', 's', 'i', 'p', 'r/r')
|
||||||
|
|
||||||
|
|
||||||
class EventIdentifierTest(unittest.TestCase):
|
class EventIdentifierTest(testtools.TestCase):
|
||||||
def test_event_init(self):
|
def test_event_init(self):
|
||||||
si = identifier.HeatIdentifier('t', 's', 'i')
|
si = identifier.HeatIdentifier('t', 's', 'i')
|
||||||
pi = identifier.ResourceIdentifier(resource_name='p', **si)
|
pi = identifier.ResourceIdentifier(resource_name='p', **si)
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import testtools
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from heat.engine import parameters
|
from heat.engine import parameters
|
||||||
|
|
||||||
|
|
||||||
class ParameterTest(unittest.TestCase):
|
class ParameterTest(testtools.TestCase):
|
||||||
def test_new_string(self):
|
def test_new_string(self):
|
||||||
p = parameters.Parameter('p', {'Type': 'String'})
|
p = parameters.Parameter('p', {'Type': 'String'})
|
||||||
self.assertTrue(isinstance(p, parameters.StringParam))
|
self.assertTrue(isinstance(p, parameters.StringParam))
|
||||||
|
@ -268,7 +268,7 @@ params_schema = json.loads('''{
|
||||||
}''')
|
}''')
|
||||||
|
|
||||||
|
|
||||||
class ParametersTest(unittest.TestCase):
|
class ParametersTest(testtools.TestCase):
|
||||||
def test_pseudo_params(self):
|
def test_pseudo_params(self):
|
||||||
params = parameters.Parameters('test_stack', {"Parameters": {}})
|
params = parameters.Parameters('test_stack', {"Parameters": {}})
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,13 @@
|
||||||
|
|
||||||
import pkgutil
|
import pkgutil
|
||||||
import sys
|
import sys
|
||||||
import unittest
|
import testtools
|
||||||
|
|
||||||
import heat.engine
|
import heat.engine
|
||||||
from heat.common import plugin_loader
|
from heat.common import plugin_loader
|
||||||
|
|
||||||
|
|
||||||
class PluginLoaderTest(unittest.TestCase):
|
class PluginLoaderTest(testtools.TestCase):
|
||||||
def test_module_name(self):
|
def test_module_name(self):
|
||||||
self.assertEqual(plugin_loader._module_name('foo.bar', 'blarg.wibble'),
|
self.assertEqual(plugin_loader._module_name('foo.bar', 'blarg.wibble'),
|
||||||
'foo.bar.blarg.wibble')
|
'foo.bar.blarg.wibble')
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import testtools
|
||||||
|
|
||||||
from heat.engine import properties
|
from heat.engine import properties
|
||||||
from heat.common import exception
|
from heat.common import exception
|
||||||
|
|
||||||
|
|
||||||
class PropertyTest(unittest.TestCase):
|
class PropertyTest(testtools.TestCase):
|
||||||
def test_required_default(self):
|
def test_required_default(self):
|
||||||
p = properties.Property({'Type': 'String'})
|
p = properties.Property({'Type': 'String'})
|
||||||
self.assertFalse(p.required())
|
self.assertFalse(p.required())
|
||||||
|
@ -256,8 +256,9 @@ class PropertyTest(unittest.TestCase):
|
||||||
self.assertRaises(TypeError, p.validate_data, [42, 'fish'])
|
self.assertRaises(TypeError, p.validate_data, [42, 'fish'])
|
||||||
|
|
||||||
|
|
||||||
class PropertiesTest(unittest.TestCase):
|
class PropertiesTest(testtools.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
super(PropertiesTest, self).setUp()
|
||||||
schema = {
|
schema = {
|
||||||
'int': {'Type': 'Integer'},
|
'int': {'Type': 'Integer'},
|
||||||
'string': {'Type': 'String'},
|
'string': {'Type': 'String'},
|
||||||
|
@ -301,7 +302,7 @@ class PropertiesTest(unittest.TestCase):
|
||||||
self.assertEqual(self.props.get('foo', 'wibble'), 'wibble')
|
self.assertEqual(self.props.get('foo', 'wibble'), 'wibble')
|
||||||
|
|
||||||
|
|
||||||
class PropertiesValidationTest(unittest.TestCase):
|
class PropertiesValidationTest(testtools.TestCase):
|
||||||
def test_required(self):
|
def test_required(self):
|
||||||
schema = {'foo': {'Type': 'String', 'Required': True}}
|
schema = {'foo': {'Type': 'String', 'Required': True}}
|
||||||
props = properties.Properties(schema, {'foo': 'bar'})
|
props = properties.Properties(schema, {'foo': 'bar'})
|
||||||
|
|
|
@ -376,10 +376,7 @@ class MetadataTest(HeatTestCase):
|
||||||
self.res = generic_rsrc.GenericResource('metadata_resource',
|
self.res = generic_rsrc.GenericResource('metadata_resource',
|
||||||
tmpl, self.stack)
|
tmpl, self.stack)
|
||||||
scheduler.TaskRunner(self.res.create)()
|
scheduler.TaskRunner(self.res.create)()
|
||||||
|
self.addCleanup(self.stack.delete)
|
||||||
def tearDown(self):
|
|
||||||
self.stack.delete()
|
|
||||||
super(HeatTestCase, self).tearDown()
|
|
||||||
|
|
||||||
def test_read_initial(self):
|
def test_read_initial(self):
|
||||||
self.assertEqual(self.res.metadata, {'Test': 'Initial metadata'})
|
self.assertEqual(self.res.metadata, {'Test': 'Initial metadata'})
|
||||||
|
|
|
@ -21,7 +21,7 @@ Unit Tests for heat.rpc.client
|
||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
import stubout
|
import stubout
|
||||||
import unittest
|
import testtools
|
||||||
|
|
||||||
from heat.common import config
|
from heat.common import config
|
||||||
from heat.common import context
|
from heat.common import context
|
||||||
|
@ -31,7 +31,7 @@ from heat.rpc import client as rpc_client
|
||||||
from heat.openstack.common import rpc
|
from heat.openstack.common import rpc
|
||||||
|
|
||||||
|
|
||||||
class EngineRpcAPITestCase(unittest.TestCase):
|
class EngineRpcAPITestCase(testtools.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
config.register_engine_opts()
|
config.register_engine_opts()
|
||||||
|
|
|
@ -101,9 +101,6 @@ Resources:
|
||||||
quantumclient.Client, 'delete_security_group_rule')
|
quantumclient.Client, 'delete_security_group_rule')
|
||||||
self.m.StubOutWithMock(quantumclient.Client, 'delete_security_group')
|
self.m.StubOutWithMock(quantumclient.Client, 'delete_security_group')
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
super(SecurityGroupTest, self).tearDown()
|
|
||||||
|
|
||||||
def create_stack(self, template):
|
def create_stack(self, template):
|
||||||
t = template_format.parse(template)
|
t = template_format.parse(template)
|
||||||
self.stack = self.parse_stack(t)
|
self.stack = self.parse_stack(t)
|
||||||
|
|
|
@ -13,13 +13,13 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
|
||||||
import unittest
|
import testtools
|
||||||
|
|
||||||
from heat.common import short_id
|
from heat.common import short_id
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
class ShortIdTest(unittest.TestCase):
|
class ShortIdTest(testtools.TestCase):
|
||||||
|
|
||||||
def test_byte_string_8(self):
|
def test_byte_string_8(self):
|
||||||
self.assertEqual(short_id._to_byte_string(0xab, 8), '\xab')
|
self.assertEqual(short_id._to_byte_string(0xab, 8), '\xab')
|
||||||
|
|
|
@ -10,6 +10,7 @@ hacking>=0.5.3,<0.6
|
||||||
coverage
|
coverage
|
||||||
discover
|
discover
|
||||||
mox==0.5.3
|
mox==0.5.3
|
||||||
|
testtools>=0.9.29
|
||||||
testrepository>=0.0.13
|
testrepository>=0.0.13
|
||||||
paramiko
|
paramiko
|
||||||
python-glanceclient
|
python-glanceclient
|
||||||
|
|
Loading…
Reference in New Issue