Simplify setting up test notifier

Rather than duplicating the test notifier module name, just use the
__name__ attribute on the module itself.

Also, where we were using stubout to set the notification_driver
flag, switch to using cfg's set_override() mechanism.

Change-Id: I46f705f71a4a220c235618491e06602fa4ea7a47
This commit is contained in:
Mark McLoughlin
2012-09-07 09:23:58 +01:00
parent 6fc0141735
commit 92102ff4c7
2 changed files with 4 additions and 6 deletions

View File

@@ -51,9 +51,8 @@ class VolumeTestCase(test.TestCase):
self.compute = importutils.import_object(FLAGS.compute_manager) self.compute = importutils.import_object(FLAGS.compute_manager)
vol_tmpdir = tempfile.mkdtemp() vol_tmpdir = tempfile.mkdtemp()
self.flags(compute_driver='nova.virt.fake.FakeDriver', self.flags(compute_driver='nova.virt.fake.FakeDriver',
volumes_dir=vol_tmpdir) volumes_dir=vol_tmpdir,
self.stubs.Set(nova.flags.FLAGS, 'notification_driver', notification_driver=[test_notifier.__name__])
['nova.openstack.common.notifier.test_notifier'])
self.stubs.Set(iscsi.TgtAdm, '_get_target', self.fake_get_target) self.stubs.Set(iscsi.TgtAdm, '_get_target', self.fake_get_target)
self.volume = importutils.import_object(FLAGS.volume_manager) self.volume = importutils.import_object(FLAGS.volume_manager)
self.context = context.get_admin_context() self.context = context.get_admin_context()

View File

@@ -38,9 +38,8 @@ class UsageInfoTestCase(test.TestCase):
def setUp(self): def setUp(self):
super(UsageInfoTestCase, self).setUp() super(UsageInfoTestCase, self).setUp()
self.flags(compute_driver='nova.virt.fake.FakeDriver', self.flags(compute_driver='nova.virt.fake.FakeDriver',
host='fake') host='fake',
self.stubs.Set(flags.FLAGS, 'notification_driver', notification_driver=[test_notifier.__name__])
['nova.openstack.common.notifier.test_notifier'])
fake_network.set_stub_network_methods(self.stubs) fake_network.set_stub_network_methods(self.stubs)
self.volume = importutils.import_object(FLAGS.volume_manager) self.volume = importutils.import_object(FLAGS.volume_manager)