def _test_update_no_prs(self, shared_es):
        self._mock_external_dict([('supported', '192.168.0.2/24')])
        es_list = [
            self.create_external_segment(
                name='supported', cidr='192.168.0.0/24', shared=shared_es,
                expected_res_status=201,
                external_routes=[{
                    'destination': '128.0.0.0/16',
                    'nexthop': '192.168.0.254'}])['external_segment']
            for x in range(3)]
        l3p_list = []
        for x in xrange(len(es_list)):
            l3p = self.create_l3_policy(
                shared=False,
                tenant_id=shared_es and 'another' or es_list[x]['tenant_id'],
                external_segments={es_list[x]['id']: []},
                expected_res_status=201)['l3_policy']
            l3p_list.append(l3p)

        ep = self.create_external_policy(
            name=APIC_EXTERNAL_EPG,
            tenant_id=es_list[0]['tenant_id'] if not shared_es else 'another',
            expected_res_status=201)['external_policy']
        ep = self.update_external_policy(
            ep['id'], expected_res_status=200, tenant_id=ep['tenant_id'],
            external_segments=[x['id'] for x in es_list])['external_policy']
        mgr = self.driver.apic_manager
        owner = (es_list[0]['tenant_id'] if not shared_es
                 else self.common_tenant)
        l3p_owner = l3p_list[0]['tenant_id']
        expected_create_calls = []
        for x in range(len(es_list)):
            es = es_list[x]
            l3p = l3p_list[x]
            if self.nat_enabled:
                if not self.pre_l3out:
                    expected_create_calls.append(
                        mock.call(es['id'], subnet='0.0.0.0/0',
                            external_epg="default-%s" % es['id'],
                            owner=owner, transaction=mock.ANY))
                expected_create_calls.append(
                    mock.call("Shd-%s-%s" % (l3p['id'], es['id']),
                         subnet='128.0.0.0/16',
                         external_epg="Shd-%s-%s" % (l3p['id'], ep['id']),
                         owner=l3p_owner, transaction=mock.ANY))
            elif not self.pre_l3out:
                expected_create_calls.append(
                    mock.call(es['id'], subnet='128.0.0.0/16',
                        external_epg=ep['id'],
                        owner=owner, transaction=mock.ANY))
        self._check_call_list(expected_create_calls,
                              mgr.ensure_external_epg_created.call_args_list)
        if self.nat_enabled:
            expected_contract_calls = []
            ext_epg_tenant = (APIC_PRE_L3OUT_TENANT if self.pre_l3out
                              else owner)
            for x in range(len(es_list)):
                es = es_list[x]
                ext_epg = (APIC_EXTERNAL_EPG if self.pre_l3out
                           else "default-%s" % es['id'])
                es_name = es['name' if self.pre_l3out else 'id']
                nat_contract = "NAT-allow-%s" % es['id']
                expected_contract_calls.extend([
                    mock.call(es_name, nat_contract,
                        external_epg=ext_epg, owner=ext_epg_tenant,
                        provided=True, transaction=mock.ANY),
                    mock.call(es_name, nat_contract,
                        external_epg=ext_epg, owner=ext_epg_tenant,
                        provided=False, transaction=mock.ANY)])
            self._check_call_list(expected_contract_calls,
                  mgr.set_contract_for_external_epg.call_args_list)
        else:
            self.assertFalse(mgr.set_contract_for_external_epg.called)

        ep = self.update_external_policy(
            ep['id'], expected_res_status=200, tenant_id=ep['tenant_id'],
            external_segments=[])['external_policy']
        mgr = self.driver.apic_manager
        expected_create_calls = []
        for x in range(len(es_list)):
            es = es_list[x]
            l3p = l3p_list[x]
            if self.nat_enabled:
                if not self.pre_l3out:
                    expected_create_calls.append(
                        mock.call(es['id'], owner=owner,
                        external_epg="default-%s" % es['id']))
                expected_create_calls.append(
                    mock.call("Shd-%s-%s" % (l3p['id'], es['id']),
                         owner=l3p_owner,
                         external_epg="Shd-%s-%s" % (l3p['id'], ep['id'])))
            elif not self.pre_l3out:
                expected_create_calls.append(
                    mock.call(es['id'], owner=owner, external_epg=ep['id']))
        self._check_call_list(expected_create_calls,
                              mgr.ensure_external_epg_deleted.call_args_list)
        if self.nat_enabled and self.pre_l3out:
            expected_contract_calls = []
            ext_epg_tenant = APIC_PRE_L3OUT_TENANT
            for x in range(len(es_list)):
                es = es_list[x]
                nat_contract = "NAT-allow-%s" % es['id']
                expected_contract_calls.extend([
                    mock.call(es['name'], nat_contract,
                        external_epg=APIC_EXTERNAL_EPG, owner=ext_epg_tenant,
                        provided=True, transaction=mock.ANY),
                    mock.call(es['name'], nat_contract,
                        external_epg=APIC_EXTERNAL_EPG, owner=ext_epg_tenant,
                        provided=False, transaction=mock.ANY)])
            self._check_call_list(expected_contract_calls,
                  mgr.unset_contract_for_external_epg.call_args_list)
        else:
            self.assertFalse(mgr.unset_contract_for_external_epg.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/TestExternalPolicy._test_update_no_prs/original