diff --git a/moniker/tests/test_notification_handler/__init__.py b/moniker/tests/test_notification_handler/__init__.py index 8c12e19ec..b8906baa0 100644 --- a/moniker/tests/test_notification_handler/__init__.py +++ b/moniker/tests/test_notification_handler/__init__.py @@ -16,17 +16,27 @@ import json import os from moniker.notification_handler.base import Handler -from moniker.tests.test_plugins import PluginTestCase +from moniker.tests import TestCase FIXTURES_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'sample_notifications')) -class NotificationHandlerTestCase(PluginTestCase): +class NotificationHandlerTestCase(TestCase): __test__ = False __plugin_base__ = Handler + def setUp(self): + super(NotificationHandlerTestCase, self).setUp() + + self.central_service = self.get_central_service() + self.central_service.start() + + def tearDown(self): + self.central_service.stop() + super(NotificationHandlerTestCase, self).tearDown() + def get_notification_fixture(self, service, name): filename = os.path.join(FIXTURES_PATH, service, '%s.json' % name) @@ -43,20 +53,3 @@ class NotificationHandlerTestCase(PluginTestCase): with self.assertRaises(ValueError): self.plugin.process_notification(event_type, 'payload') - - def pre_invoke(self): - self.central_service = self.get_central_service() - self.invoke_args = [self.central_service] - - -class AddressHandlerTestCase(NotificationHandlerTestCase): - """ - Test something that receives notifications with regards to addresses - """ - def pre_invoke(self): - super(AddressHandlerTestCase, self).pre_invoke() - - domain = self.create_domain() - self.domain_id = str(domain['id']) - - return {'domain_id': self.domain_id} diff --git a/moniker/tests/test_notification_handler/test_nova.py b/moniker/tests/test_notification_handler/test_nova.py index 2803b3e1f..d60fee6ee 100644 --- a/moniker/tests/test_notification_handler/test_nova.py +++ b/moniker/tests/test_notification_handler/test_nova.py @@ -14,14 +14,23 @@ # License for the specific language governing permissions and limitations # under the License. from moniker.openstack.common import log as logging -from moniker.tests.test_notification_handler import AddressHandlerTestCase +from moniker.notification_handler.nova import NovaFixedHandler +from moniker.tests.test_notification_handler import NotificationHandlerTestCase LOG = logging.getLogger(__name__) -class NovaTestCase(AddressHandlerTestCase): +class NovaFixedHandlerTest(NotificationHandlerTestCase): __test__ = True - __plugin_name__ = 'nova_fixed' + + def setUp(self): + super(NovaFixedHandlerTest, self).setUp() + + domain = self.create_domain() + self.domain_id = domain['id'] + self.config(domain_id=domain['id'], group='handler:nova_fixed') + + self.plugin = NovaFixedHandler(self.central_service) def test_instance_create_end(self): event_type = 'compute.instance.create.end' diff --git a/moniker/tests/test_notification_handler/test_quantum.py b/moniker/tests/test_notification_handler/test_quantum.py index 875c24b9e..0c98673b1 100644 --- a/moniker/tests/test_notification_handler/test_quantum.py +++ b/moniker/tests/test_notification_handler/test_quantum.py @@ -14,14 +14,23 @@ # License for the specific language governing permissions and limitations # under the License. from moniker.openstack.common import log as logging -from moniker.tests.test_notification_handler import AddressHandlerTestCase +from moniker.notification_handler.quantum import QuantumFloatingHandler +from moniker.tests.test_notification_handler import NotificationHandlerTestCase LOG = logging.getLogger(__name__) -class QuantumFloatingTestCase(AddressHandlerTestCase): +class QuantumFloatingHandlerTest(NotificationHandlerTestCase): __test__ = True - __plugin_name__ = 'quantum_floatingip' + + def setUp(self): + super(QuantumFloatingHandlerTest, self).setUp() + + domain = self.create_domain() + self.domain_id = domain['id'] + self.config(domain_id=domain['id'], group='handler:quantum_floatingip') + + self.plugin = QuantumFloatingHandler(self.central_service) def test_floatingip_associate(self): event_type = 'floatingip.update.end' diff --git a/moniker/tests/test_plugins/__init__.py b/moniker/tests/test_plugins/__init__.py deleted file mode 100644 index 4f189cd09..000000000 --- a/moniker/tests/test_plugins/__init__.py +++ /dev/null @@ -1,44 +0,0 @@ -from moniker.tests import TestCase - - -class PluginTestCase(TestCase): - __test__ = False - - __plugin_base__ = None - __plugin_name__ = None - - def setUp(self): - super(PluginTestCase, self).setUp() - - self.invoke_args = [] - self.invoke_kwds = {} - - # NOTE: In case overrider of _pre_invoke forgets to return {} - plugin_opts = self.pre_invoke() or {} - - # NOTE: Load plugin and register it's opts - plugin_cls = self.get_plugin() - - self.config(group=plugin_cls.get_canonical_name(), **plugin_opts) - - self.plugin = self.get_plugin( - invoke_args=self.invoke_args, - invoke_kwds=self.invoke_kwds, - invoke_on_load=True) - - def get_plugin(self, **kw): - """ - Override me - """ - print self.__plugin_base__.__plugin_ns__, self.__plugin_name__ - return self.__plugin_base__.get_plugin(self.__plugin_name__, **kw) - - def pre_invoke(self): - """ - Do something before invoking the actual plugin, returned hash will - be passed to self.config() - - Also you can manipulate self.invoke_args and self.invoke_kwds to your - likings here - """ - return {}