def _test_create_with_prs(self, shared_es, shared_prs):
        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)
        prov = self._create_policy_rule_set_on_shared(
            shared=shared_prs,
            tenant_id=es_list[0]['tenant_id'] if not (
                shared_es | shared_prs) else 'another')
        cons = self._create_policy_rule_set_on_shared(
            shared=shared_prs,
            tenant_id=es_list[0]['tenant_id'] if not (
                shared_es | shared_prs) else 'another')
        ep = self.create_external_policy(
            name=APIC_EXTERNAL_EPG,
            provided_policy_rule_sets={prov['id']: ''},
            consumed_policy_rule_sets={cons['id']: ''},
            tenant_id=es_list[0]['tenant_id'] if not shared_es else 'another',
            external_segments=[x['id'] for x in es_list],
            expected_res_status=201)['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_calls = []
        for x in range(len(es_list)):
            es = es_list[x]
            l3p = l3p_list[x]
            nat = self.nat_enabled
            external_epg = APIC_EXTERNAL_EPG if self.pre_l3out else (
                ("default-%s" % es['id']) if nat else ep['id'])
            ext_epg_tenant = (APIC_PRE_L3OUT_TENANT if self.pre_l3out else
                              owner)
            es_name = es['name' if self.pre_l3out else 'id']
            expected_calls.append(
                mock.call(es_name,
                    ("NAT-allow-%s" % es['id']) if nat else prov['id'],
                    external_epg=external_epg,
                    provided=True, owner=ext_epg_tenant,
                    transaction=mock.ANY))
            expected_calls.append(
                mock.call(es_name,
                    ("NAT-allow-%s" % es['id']) if nat else cons['id'],
                    external_epg=external_epg,
                    provided=False, owner=ext_epg_tenant,
                    transaction=mock.ANY))
            if nat:
                expected_calls.append(
                    mock.call("Shd-%s-%s" % (l3p['id'], es['id']), prov['id'],
                        external_epg=("Shd-%s-%s" % (l3p['id'], ep['id'])),
                        provided=True, owner=l3p_owner,
                        transaction=mock.ANY))
                expected_calls.append(
                    mock.call("Shd-%s-%s" % (l3p['id'], es['id']), cons['id'],
                        external_epg=("Shd-%s-%s" % (l3p['id'], ep['id'])),
                        provided=False, owner=l3p_owner,
                        transaction=mock.ANY))
        self._check_call_list(expected_calls,
                              mgr.set_contract_for_external_epg.call_args_list)

    # 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_create_with_prs/original