本文整理汇总了Python中mimic.core.MimicCore.entries_for_tenant方法的典型用法代码示例。如果您正苦于以下问题:Python MimicCore.entries_for_tenant方法的具体用法?Python MimicCore.entries_for_tenant怎么用?Python MimicCore.entries_for_tenant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mimic.core.MimicCore
的用法示例。
在下文中一共展示了MimicCore.entries_for_tenant方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_entries_for_tenant_internal
# 需要导入模块: from mimic.core import MimicCore [as 别名]
# 或者: from mimic.core.MimicCore import entries_for_tenant [as 别名]
def test_entries_for_tenant_internal(self):
"""
Validate that the internal API shows up in the service catalog for a
given tenant.
"""
iapi = make_example_internal_api(self)
core = MimicCore(Clock(), [iapi])
prefix_map = {}
base_uri = "http://some/random/prefix"
catalog_entries = [
entry
for entry in core.entries_for_tenant(
'some-tenant',
prefix_map,
base_uri
)
]
self.assertEqual(len(core._uuid_to_api_internal), 1)
self.assertEqual(len(core._uuid_to_api_external), 0)
self.assertEqual(len(catalog_entries), 1)
self.assertEqual(catalog_entries[0].type, "serviceType")
self.assertEqual(catalog_entries[0].name, "serviceName")
self.assertEqual(catalog_entries[0].tenant_id, "some-tenant")
self.assertEqual(len(catalog_entries[0].endpoints), 1)
示例2: test_no_uuids_if_no_plugins
# 需要导入模块: from mimic.core import MimicCore [as 别名]
# 或者: from mimic.core.MimicCore import entries_for_tenant [as 别名]
def test_no_uuids_if_no_plugins(self):
"""
If there are no plugins provided to :class:`MimicCore`, there are no
uri prefixes or entries for the tenant.
"""
core = MimicCore(Clock(), [])
self.assertEqual(0, len(core._uuid_to_api))
self.assertEqual([], list(core.entries_for_tenant("any_tenant", {}, "http://mimic")))
示例3: test_no_uri_prefixes_if_no_plugins
# 需要导入模块: from mimic.core import MimicCore [as 别名]
# 或者: from mimic.core.MimicCore import entries_for_tenant [as 别名]
def test_no_uri_prefixes_if_no_plugins(self):
"""
If there are no plugins provided to :class:`MimicCore`, there are no
uri prefixes or entries for the tenant.
"""
core = MimicCore(Clock(), [])
self.assertEqual(0, len(core.uri_prefixes))
self.assertEqual([], list(core.entries_for_tenant('any_tenant', {},
'http://mimic')))
示例4: test_entries_for_tenant_combined
# 需要导入模块: from mimic.core import MimicCore [as 别名]
# 或者: from mimic.core.MimicCore import entries_for_tenant [as 别名]
def test_entries_for_tenant_combined(self):
"""
Validate that both internal and external APIs show up in the service
catalog for a given tenant.
"""
eeapi = make_example_external_api(
self,
name=self.eeapi_name,
set_enabled=True
)
core = MimicCore(Clock(), [eeapi, make_example_internal_api(self)])
prefix_map = {}
base_uri = "http://some/random/prefix"
catalog_entries = [
entry
for entry in core.entries_for_tenant(
'some-tenant',
prefix_map,
base_uri
)
]
self.assertEqual(len(core._uuid_to_api_internal), 1)
self.assertEqual(len(core._uuid_to_api_external), 1)
self.assertEqual(len(catalog_entries), 2)
found_internal = False
found_external = False
for catalog_entry in catalog_entries:
if catalog_entry.name == eeapi.name_key:
found_external = True
self.assertEqual(catalog_entry.type, eeapi.type_key)
self.assertEqual(catalog_entry.name, eeapi.name_key)
self.assertEqual(catalog_entry.tenant_id, "some-tenant")
self.assertEqual(len(catalog_entry.endpoints), 1)
elif catalog_entry.name == "serviceName":
found_internal = True
self.assertEqual(catalog_entry.type, "serviceType")
self.assertEqual(catalog_entry.name, "serviceName")
self.assertEqual(catalog_entry.tenant_id, "some-tenant")
self.assertEqual(len(catalog_entry.endpoints), 1)
self.assertTrue(found_internal)
self.assertTrue(found_external)
示例5: test_entries_for_tenant_external_with_tenantid_replacement
# 需要导入模块: from mimic.core import MimicCore [as 别名]
# 或者: from mimic.core.MimicCore import entries_for_tenant [as 别名]
def test_entries_for_tenant_external_with_tenantid_replacement(self):
"""
Validate that the external API shows up in the service catalog for a
given tenant and the tenant id is in the URL.
"""
eeapi = make_example_external_api(
self,
name=self.eeapi_name,
set_enabled=True
)
tenant_id = 'some-tenant-other'
ept_internal_url = "http://internal.url/v1/" + tenant_id
ept_public_url = "http://public.url/v1/" + tenant_id
for ept in eeapi.endpoint_templates.values():
ept.internal_url = "http://internal.url/v1/%tenant_id%"
ept.public_url = "http://public.url/v1/%tenant_id%"
core = MimicCore(Clock(), [eeapi])
prefix_map = {}
base_uri = "http://some/random/prefix"
catalog_entries = [
entry
for entry in core.entries_for_tenant(
tenant_id,
prefix_map,
base_uri
)
]
self.assertEqual(len(core._uuid_to_api_internal), 0)
self.assertEqual(len(core._uuid_to_api_external), 1)
self.assertEqual(len(catalog_entries), 1)
self.assertEqual(catalog_entries[0].type, eeapi.type_key)
self.assertEqual(catalog_entries[0].name, eeapi.name_key)
self.assertEqual(catalog_entries[0].tenant_id, tenant_id)
self.assertEqual(len(catalog_entries[0].endpoints), 1)
self.assertEqual(
catalog_entries[0].endpoints[0].internal_url,
ept_internal_url
)
self.assertEqual(
catalog_entries[0].endpoints[0].complete_url,
ept_public_url
)
示例6: test_entries_for_tenant_external_multiple_regions
# 需要导入模块: from mimic.core import MimicCore [as 别名]
# 或者: from mimic.core.MimicCore import entries_for_tenant [as 别名]
def test_entries_for_tenant_external_multiple_regions(self):
"""
Test with multiple regions for the External APIs.
"""
iapi = make_example_internal_api(self)
eeapi = make_example_external_api(
self,
name=self.eeapi_name,
set_enabled=True
)
eeapi2_name = "alternate-external-api"
eeapi2_template_id = u"uuid-alternate-endpoint-template"
eeapi2_template = exampleEndpointTemplate(
name=eeapi2_name,
endpoint_uuid=eeapi2_template_id,
region=u"NEW_REGION",
url=u"https://api.new_region.example.com:9090"
)
eeapi2 = make_example_external_api(
self,
name=eeapi2_name,
endpoint_templates=[eeapi2_template],
set_enabled=True
)
core = MimicCore(Clock(), [eeapi, eeapi2, iapi])
prefix_map = {}
base_uri = "http://some/random/prefix"
catalog_entries = [
entry
for entry in core.entries_for_tenant(
'some-tenant',
prefix_map,
base_uri
)
]
self.assertEqual(len(core._uuid_to_api_internal), 1)
self.assertEqual(len(core._uuid_to_api_external), 2)
self.assertEqual(len(catalog_entries), 3)
found_internal = False
found_first_external = False
found_second_external = False
for catalog_entry in catalog_entries:
if catalog_entry.name == eeapi.name_key:
found_first_external = True
self.assertEqual(catalog_entry.type, eeapi.type_key)
self.assertEqual(catalog_entry.name, eeapi.name_key)
self.assertEqual(catalog_entry.tenant_id, "some-tenant")
self.assertEqual(len(catalog_entry.endpoints), 1)
elif catalog_entry.name == eeapi2.name_key:
found_second_external = True
self.assertEqual(catalog_entry.type, eeapi2.type_key)
self.assertEqual(catalog_entry.name, eeapi2.name_key)
self.assertEqual(catalog_entry.tenant_id, "some-tenant")
self.assertEqual(len(catalog_entry.endpoints), 1)
elif catalog_entry.name == "serviceName":
found_internal = True
self.assertEqual(catalog_entry.type, "serviceType")
self.assertEqual(catalog_entry.name, "serviceName")
self.assertEqual(catalog_entry.tenant_id, "some-tenant")
self.assertEqual(len(catalog_entry.endpoints), 1)
self.assertTrue(found_internal)
self.assertTrue(found_first_external)
self.assertTrue(found_second_external)