def _test_route_update_remove(self, shared_es):
        # Verify routes are updated correctly
        self._mock_external_dict([('supported', '192.168.0.2/24')])
        es = self.create_external_segment(
            name='supported', cidr='192.168.0.0/24', shared=shared_es,
            external_routes=[{'destination': '0.0.0.0/0',
                              'nexthop': '192.168.0.254'},
                             {'destination': '128.0.0.0/16',
                              'nexthop': None}],
            expected_res_status=201)['external_segment']

        # create L3-policies
        if self.pre_l3out and not self.nat_enabled:
            tenants = [es['tenant_id']]
        else:
            tenants = (['tenant_a', 'tenant_b', 'tenant_c']
                       if self.nat_enabled and shared_es
                       else [es['tenant_id']])
        l3p_list = []
        for x in xrange(len(tenants)):
            l3p = self.create_l3_policy(
                shared=False,
                tenant_id=tenants[x],
                external_segments={es['id']: []},
                expected_res_status=201)['l3_policy']
            l3p_list.append(l3p)

        # Attach external policy
        f = self.create_external_policy
        eps = [f(external_segments=[es['id']],
                 tenant_id=tenants[x],
                 expected_res_status=201)['external_policy']
               for x in xrange(len(tenants))]
        mgr = self.driver.apic_manager
        owner = es['tenant_id'] if not shared_es else self.common_tenant
        mgr.ensure_external_epg_created.reset_mock()
        mgr.ensure_static_route_created.reset_mock()
        # Remove route completely
        self.update_external_segment(es['id'], expected_res_status=200,
                                     external_routes=[
                                         {'destination': '0.0.0.0/0',
                                          'nexthop': '192.168.0.254'}])
        mgr = self.driver.apic_manager
        if not self.pre_l3out:
            mgr.ensure_static_route_deleted.assert_called_with(
                es['id'], mocked.APIC_EXT_SWITCH, '128.0.0.0/16',
                owner=owner, transaction=mock.ANY)
        else:
            self.assertFalse(mgr.ensure_static_route_deleted.called)
        expected_delete_calls = []
        for x in range(len(tenants)):
            ep = eps[x]
            l3p = l3p_list[x]
            l3out = es['name' if self.pre_l3out else 'id']
            ext_epg = ep['id']
            tenant = APIC_PRE_L3OUT_TENANT if self.pre_l3out else owner
            if self.nat_enabled:
                l3out = "Shd-%s-%s" % (l3p['id'], es['id'])
                ext_epg = "Shd-%s-%s" % (l3p['id'], ext_epg)
                tenant = tenants[x]
            expected_delete_calls.append(
                mock.call(l3out, subnets=['128.0.0.0/16'],
                          external_epg=ext_epg, owner=tenant,
                          transaction=mock.ANY))
        self._check_call_list(
            expected_delete_calls,
            mgr.ensure_external_epg_routes_deleted.call_args_list)
        self.assertFalse(mgr.ensure_static_route_created.called)
        self.assertFalse(mgr.ensure_external_epg_created.called)
        self.assertFalse(mgr.ensure_next_hop_deleted.called)

        # Remove nexthop only
        mgr.ensure_static_route_deleted.reset_mock()
        mgr.ensure_external_epg_routes_deleted.reset_mock()

        self.update_external_segment(es['id'], expected_res_status=200,
                                     external_routes=[
                                         {'destination': '0.0.0.0/0',
                                          'nexthop': None}])
        if not self.pre_l3out:
            mgr.ensure_next_hop_deleted.assert_called_with(
                es['id'], mocked.APIC_EXT_SWITCH, '0.0.0.0/0', '192.168.0.254',
                owner=owner, transaction=mock.ANY)
            # Being the new nexthop 'None', the default one is used
            mgr.ensure_static_route_created.assert_called_with(
                es['id'], mocked.APIC_EXT_SWITCH, '192.168.0.1',
                subnet='0.0.0.0/0', owner=owner, transaction=mock.ANY)
        else:
            self.assertFalse(mgr.ensure_static_route_created.called)
            self.assertFalse(mgr.ensure_next_hop_deleted.called)

        expected_delete_calls = []
        for x in range(len(tenants)):
            ep = eps[x]
            l3p = l3p_list[x]
            l3out = es['name' if self.pre_l3out else 'id']
            ext_epg = ep['id']
            tenant = APIC_PRE_L3OUT_TENANT if self.pre_l3out else owner
            if self.nat_enabled:
                l3out = "Shd-%s-%s" % (l3p['id'], es['id'])
                ext_epg = "Shd-%s-%s" % (l3p['id'], ext_epg)
                tenant = tenants[x]
            expected_delete_calls.append(
                mock.call(l3out, subnet='0.0.0.0/0',
                          external_epg=ext_epg, owner=tenant,
                          transaction=mock.ANY))
        self._check_call_list(expected_delete_calls,
                              mgr.ensure_external_epg_created.call_args_list)

        self.assertFalse(mgr.ensure_static_route_deleted.called)
        self.assertFalse(mgr.ensure_external_epg_routes_deleted.called)

    # Although the naming convention used here has been chosen poorly,
    # I'm separating the tests in order to get the mock re-set.
dataset/ETHPy150Open openstack/group-based-policy/gbpservice/neutron/tests/unit/services/grouppolicy/test_apic_mapping.py/TestExternalSegment._test_route_update_remove/original