'Add and remove one pd-enabled subnet
Remove the interface by deleting it from the router'

@mock.patch.object(pd.PrefixDelegation, 'update_subnet')
@mock.patch.object(dibbler.PDDibbler, 'get_prefix', autospec=True)
@mock.patch.object(dibbler.os, 'getpid', return_value=1234)
@mock.patch.object(pd.PrefixDelegation, '_is_lla_active', return_value=True)
@mock.patch.object(dibbler.os, 'chmod')
@mock.patch.object(dibbler.shutil, 'rmtree')
@mock.patch.object(pd.PrefixDelegation, '_get_sync_data')
def test_pd_add_remove_subnet(self, mock1, mock2, mock3, mock4, mock_getpid, mock_get_prefix, mock_pd_update_subnet):

    (agent, router, ri) = self._pd_setup_agent_router()
    l3_test_common.router_append_pd_enabled_subnet(router)
    ri.process()
    self.assertFalse(self.external_process.call_count)
    self.assertFalse(mock_get_prefix.call_count)
    self._pd_add_gw_interface(agent, ri)
    update_router = copy.deepcopy(router)
    pd_intfs = l3_test_common.get_unassigned_pd_interfaces(update_router)
    subnet_id = pd_intfs[0]['subnets'][0]['id']
    prefix = self._pd_get_prefixes(agent, ri, [], pd_intfs, mock_get_prefix)
    ri.router = update_router
    ri.process()
    self._pd_verify_update_results(ri, pd_intfs, mock_pd_update_subnet)
    self.assertEqual({subnet_id: prefix}, ri.pd_subnets)
    ri._process_pd_iptables_rules.assert_called_once_with(prefix, subnet_id)
    self._pd_remove_interfaces(pd_intfs, agent, ri)
    self.assertEqual({}, ri.pd_subnets)
