def test_delete_router(self, l3_nat, driver):
        router_id, _ = self._get_router_test()
        context = self._get_mock_network_operation_context()
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        hook.delete_router(context, router_id)

        hook.driver.delete_router.assert_called_with(context, router_id)
    def test_update_router(self, extra_route, driver):
        router_id, router = self._get_router_test()
        context = self._get_mock_network_operation_context()
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        hook.update_router(context, router_id, router)

        hook.driver.update_router.assert_called_with(context, router_id,
                                                     router)
    def test_create_router(self, l3_nat, driver):
        router_id, router = self._get_router_test()
        context = self._get_mock_network_operation_context()
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()
        new_router = router
        new_router['id'] = router_id

        hook.create_router(context, router)

        hook.driver.create_router.assert_called_with(context, router)
    def test_create_floatingip(self, l3_nat, driver, snat_sync):
        context = get_mock_network_operation_context()
        floatingip = self._get_floating_ip()
        l3_nat.return_value = floatingip
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        hook.create_floatingip(context, floatingip)

        l3_nat.assert_called_with(context, mock.ANY, mock.ANY)
        hook.driver.create_floatingip.assert_called_with(context, mock.ANY)
    def test_remove_router_interface(self, l3_nat, driver, snat_sync):
        router_id, _ = self._get_router_test()
        interface_info = self._get_interface_info()
        context = get_mock_network_operation_context()
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        hook.remove_router_interface(context, router_id, interface_info)

        hook.driver.remove_router_interface.assert_called_with(
            context, router_id, interface_info)
    def test_delete_router(self, l3_nat, driver, snat_sync):
        router_id, _ = self._get_router_test()
        context = get_mock_network_operation_context()
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()
        mock.patch.object(hook, "snat_sync")

        hook.delete_router(context, router_id)

        hook.driver.delete_router.assert_called_with(context, router_id)
        hook.snat_sync.sync_snat_interfaces.assert_called_once()
    def test_add_router_interface(self, l3_nat, driver):
        router_id, _ = self._get_router_test()
        interface_info = self._get_interface_info()
        context = self._get_mock_network_operation_context()
        l3_nat.return_value = interface_info
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        hook.add_router_interface(context, router_id, interface_info)

        hook.driver.add_router_interface.assert_called_with(context,
                                                            router_id,
                                                            mock.ANY)
    def test_delete_floatingip(self, l3_nat, l3_get, driver, snat_sync):
        context = get_mock_network_operation_context()
        floatingip = self._get_floating_ip()
        l3_nat.return_value = floatingip
        l3_get.return_value = floatingip['floatingip']
        fip_id = floatingip['floatingip']['id']
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        hook.delete_floatingip(context, fip_id)

        l3_nat.assert_called_with(context, fip_id)
        hook.driver.delete_floatingip.assert_called_with(context, fip_id)
    def test_update_floatingip(self, l3_nat, l3_get, driver, driver2):
        context = self._get_mock_network_operation_context()
        floatingip = self._get_floating_ip()
        l3_nat.return_value = floatingip
        l3_get.return_value = floatingip['floatingip']
        fip_id = floatingip['floatingip']['id']
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        hook.update_floatingip(context, fip_id, floatingip)

        l3_nat.assert_called_with(context, mock.ANY, mock.ANY)
        hook.driver.update_floatingip.assert_called_with(context,
                                                         fip_id,
                                                         mock.ANY)
    def test_get_plugin_description(self, _):
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        description = hook.get_plugin_description()

        self.assertIsInstance(description, six.string_types)
    def test_get_plugin_type(self, _):
        hook = opencontrail_rt_callback.OpenContrailRouterHandler()

        type = hook.get_plugin_type()

        self.assertEqual(constants.L3, type, "Wrong plugin type")