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

def test_router_is_not_removed_from_snat_agent_on_dhcp_port_deletion(self):

    router = self._create_router(distributed=True, ha=True)
    kwargs = {'arg_list': (external_net.EXTERNAL,), external_net.EXTERNAL: True}
    with self.network(**kwargs) as ext_net:
        with self.subnet(network=ext_net):
            with self.subnet(cidr='20.0.0.0/24') as subnet:
                with self.port(subnet=subnet, device_owner=constants.DEVICE_OWNER_DHCP) as port:
                    self.core_plugin.update_port(self.context, port['port']['id'], {'port': {'binding:host_id': self.l3_agent['host']}})
                    gw_info = {'network_id': ext_net['network']['id']}
                    self.l3_plugin.update_router(self.context, router['id'], {'router': {l3.EXTERNAL_GW_INFO: gw_info}})
                    self.l3_plugin.add_router_interface(self.context, router['id'], {'subnet_id': subnet['subnet']['id']})
                    self._assert_router_is_hosted_on_both_dvr_snat_agents(router)
                    notifier = self.l3_plugin.agent_notifiers[constants.AGENT_TYPE_L3]
                    with mock.patch.object(notifier, 'router_removed_from_agent', side_effect=Exception('BOOOOOOM!')) as remove_mock:
                        self._delete('ports', port['port']['id'])
                        remove_mock.assert_not_called()
                        self._assert_router_is_hosted_on_both_dvr_snat_agents(router)
