Ejemplo n.º 1
0
    def test___init__(self,):
        test_obj = backend.ServerSideRpcBackend()

        calls = [mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        trunk_consts.TRUNK,
                        events.AFTER_CREATE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        trunk_consts.TRUNK,
                        events.AFTER_DELETE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        trunk_consts.SUBPORTS,
                        events.AFTER_CREATE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        trunk_consts.SUBPORTS,
                        events.AFTER_DELETE))
                 ]
        self._mgr.subscribe.assert_has_calls(calls, any_order=True)
Ejemplo n.º 2
0
    def test___init__(self,):
        test_obj = backend.ServerSideRpcBackend()

        calls = [mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.TRUNK,
                        events.AFTER_CREATE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.TRUNK,
                        events.AFTER_DELETE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.SUBPORTS,
                        events.AFTER_CREATE)),
                 mock.call(
                    *tools.get_subscribe_args(
                        test_obj.process_event,
                        resources.SUBPORTS,
                        events.AFTER_DELETE))
                 ]
        self._mgr.subscribe.assert_has_calls(calls, any_order=True)
Ejemplo n.º 3
0
 def test_register(self):
     mock_callback = mock.Mock()
     mock_agent_type = mock.Mock()
     capabilities.register(mock_callback, mock_agent_type)
     args = tools.get_subscribe_args(mock_callback, mock_agent_type,
                                     events.AFTER_INIT)
     self._mgr.subscribe.assert_called_with(*args)
Ejemplo n.º 4
0
 def test_register(self):
     mock_callback = mock.Mock()
     mock_agent_type = mock.Mock()
     capabilities.register(mock_callback, mock_agent_type)
     args = tools.get_subscribe_args(
         mock_callback, mock_agent_type, events.AFTER_INIT)
     self._mgr.subscribe.assert_called_with(*args)
Ejemplo n.º 5
0
    def test_subscribe_resources_cb(self):

        class FakeResourceCB1(driver_mgr.ResourceCallBackBase):
            def handle_event(self, resource, event, trigger, **kwargs):
                pass

        class FakeResourceCB2(driver_mgr.ResourceCallBackBase):
            def handle_event(self, resource, event, trigger, **kwargs):
                pass

        driver_mgr.RESOURCE_CB_CLASS_MAP = {'fake_resource1': FakeResourceCB1,
                                            'fake_resource2': FakeResourceCB2}

        self.driver_manager._setup_resources_cb_handle()

        fake_resource_cb1 = FakeResourceCB1(
            'fake_resource1', self.driver_manager.call)
        fake_resource_cb2 = FakeResourceCB2(
            'fake_resource2', self.driver_manager.call)
        assert_calls = [
            mock.call(
                *tools.get_subscribe_args(
                    fake_resource_cb1.handle_event,
                    'fake_resource1', events.AFTER_CREATE)),
            mock.call(
                *tools.get_subscribe_args(
                    fake_resource_cb1.handle_event,
                    'fake_resource1', events.AFTER_UPDATE)),
            mock.call(
                *tools.get_subscribe_args(
                    fake_resource_cb1.handle_event,
                    'fake_resource1', events.AFTER_DELETE)),
            mock.call(
                *tools.get_subscribe_args(
                    fake_resource_cb2.handle_event,
                    'fake_resource2', events.AFTER_CREATE)),
            mock.call(
                *tools.get_subscribe_args(
                    fake_resource_cb2.handle_event,
                    'fake_resource2', events.AFTER_UPDATE)),
            mock.call(
                *tools.get_subscribe_args(
                    fake_resource_cb2.handle_event,
                    'fake_resource2', events.AFTER_DELETE)),
        ]
        self._cb_mgr.subscribe.assert_has_calls(assert_calls)
Ejemplo n.º 6
0
 def test_register(self):
     ovs_capabilities.register()
     args = tools.get_subscribe_args(
         driver.init_handler, constants.AGENT_TYPE_OVS, events.AFTER_INIT)
     self._mgr.subscribe.assert_called_with(*args)