'Test notifications for router create, update, and delete.
Make sure that when the agent sends notifications of router events
for router create, update, and delete, that the correct handler is
called with the right resource, event, and router information.'

def test_agent_notifications_for_router_events(self):

    event_handler = mock.Mock()
    registry.subscribe(event_handler, resources.ROUTER, events.BEFORE_CREATE)
    registry.subscribe(event_handler, resources.ROUTER, events.AFTER_CREATE)
    registry.subscribe(event_handler, resources.ROUTER, events.BEFORE_UPDATE)
    registry.subscribe(event_handler, resources.ROUTER, events.AFTER_UPDATE)
    registry.subscribe(event_handler, resources.ROUTER, events.BEFORE_DELETE)
    registry.subscribe(event_handler, resources.ROUTER, events.AFTER_DELETE)
    router_info = self.generate_router_info(enable_ha=False)
    router = self.manage_router(self.agent, router_info)
    self.agent._process_updated_router(router.router)
    self._delete_router(self.agent, router.router_id)
    expected_calls = [mock.call('router', 'before_create', self.agent, router=router), mock.call('router', 'after_create', self.agent, router=router), mock.call('router', 'before_update', self.agent, router=router), mock.call('router', 'after_update', self.agent, router=router), mock.call('router', 'before_delete', self.agent, router=router), mock.call('router', 'after_delete', self.agent, router=router)]
    event_handler.assert_has_calls(expected_calls)
