@mock.patch.object(ip_lib, 'IPWrapper')
@mock.patch.object(ip_lib, 'IPDevice')
def test_floating_ip_removed_dist(self, mIPDevice, mIPWrapper):
    router = mock.MagicMock()
    ri = self._create_router(router)
    ri.ex_gw_port = ri.router['gw_port']
    subnet_id = _uuid()
    fixed_ip = '0.0.0.0'
    agent_gw_port = {'fixed_ips': [{'ip_address': fixed_ip, 'prefixlen': 24, 'subnet_id': subnet_id}], 'subnets': [{'id': subnet_id, 'cidr': '20.0.0.0/24', 'gateway_ip': '0.0.0.0'}], 'id': _uuid(), 'network_id': _uuid(), 'mac_address': 'ca:fe:de:ad:be:ef'}
    fip_cidr = '11.22.33.44/24'
    ri.fip_ns = mock.Mock()
    ri.fip_ns.get_name.return_value = 'fip_ns_name'
    ri.floating_ips_dict['11.22.33.44'] = (fixed_ip, FIP_PRI)
    ri.fip_2_rtr = '11.22.33.42'
    ri.rtr_2_fip = '11.22.33.40'
    ri.fip_ns.agent_gateway_port = agent_gw_port
    s = lla.LinkLocalAddressPair('169.254.30.42/31')
    ri.rtr_fip_subnet = s
    ri.fip_ns.local_subnets = mock.Mock()
    ri.floating_ip_removed_dist(fip_cidr)
    self.mock_delete_ip_rule.assert_called_with(ri.router_namespace.name, ip=fixed_ip, table=16, priority=FIP_PRI)
    mIPDevice().route.delete_route.assert_called_with(fip_cidr, via=str(s.ip))
    ri.fip_ns.local_subnets.allocate.assert_not_called()
@mock.patch.object(ip_lib, 'IPWrapper')
@mock.patch.object(ip_lib, 'IPDevice')
def test_floating_ip_removed_dist(self, mIPDevice, mIPWrapper):
    router = mock.MagicMock()
    ri = self._create_router(router)
    ri.ex_gw_port = ri.router['gw_port']
    subnet_id = _uuid()
    fixed_ip = '0.0.0.0'
    agent_gw_port = {'fixed_ips': [{'ip_address': fixed_ip, 'prefixlen': 24, 'subnet_id': subnet_id}], 'subnets': [{'id': subnet_id, 'cidr': '20.0.0.0/24', 'gateway_ip': '0.0.0.0'}], 'id': _uuid(), 'network_id': _uuid(), 'mac_address': 'ca:fe:de:ad:be:ef'}
    fip_cidr = '11.22.33.44/24'
    ri.fip_ns = mock.Mock()
    ri.fip_ns.get_name.return_value = 'fip_ns_name'
    ri.floating_ips_dict['11.22.33.44'] = (fixed_ip, FIP_PRI)
    ri.fip_2_rtr = '11.22.33.42'
    ri.rtr_2_fip = '11.22.33.40'
    ri.fip_ns.agent_gateway_port = agent_gw_port
    s = lla.LinkLocalAddressPair('169.254.30.42/31')
    ri.rtr_fip_subnet = s
    ri.fip_ns.local_subnets = mock.Mock()
    ri.floating_ip_removed_dist(fip_cidr)
    self.mock_delete_ip_rule.assert_called_with(ri.router_namespace.name, ip=fixed_ip, table=16, priority=FIP_PRI)
    mIPDevice().route.delete_route.assert_called_with(fip_cidr, via=str(s.ip))
    ri.fip_ns.local_subnets.allocate.assert_not_called()