'Check that dvr router is not removed from l3 agent hosting
SNAT for it on router interface removal'

def test_router_is_not_removed_from_snat_agent_on_interface_removal(self):

    router = self._create_router()
    kwargs = {'arg_list': (external_net.EXTERNAL,), external_net.EXTERNAL: True}
    with self.subnet() as subnet:
        with self.network(**kwargs) as ext_net:
            with self.subnet(network=ext_net, cidr='20.0.0.0/24'):
                self.l3_plugin._update_router_gw_info(self.context, router['id'], {'network_id': ext_net['network']['id']})
                self.l3_plugin.add_router_interface(self.context, router['id'], {'subnet_id': subnet['subnet']['id']})
                agents = self.l3_plugin.list_l3_agents_hosting_router(self.context, router['id'])
                self.assertEqual(1, len(agents['agents']))
                with mock.patch.object(self.l3_plugin, '_l3_rpc_notifier') as l3_notifier:
                    self.l3_plugin.remove_router_interface(self.context, router['id'], {'subnet_id': subnet['subnet']['id']})
                    agents = self.l3_plugin.list_l3_agents_hosting_router(self.context, router['id'])
                    self.assertEqual(1, len(agents['agents']))
                    self.assertFalse(l3_notifier.router_removed_from_agent.called)
