def exampleEndpointTemplate(name=u"example", region="EXTERNAL", version="v1", url="https://api.external.example.com:8080", public_url=None, internal_url=None, admin_url=None, version_info_url=None, version_list_url=None, type_id=u"example", enabled=False, endpoint_uuid=None, tenantid_alias="%tenant_id%"): """ Create an instance of the :obj:`EndpointTemplateStore` in a usable form for testing. :param text_type name: name of the service provided, e.g Cloud Files. :param text_type region: region the service is provided in, e.g ORD. :param text_type version: version of the service, e.g v1. :param text_type url: basic URL of the service in the region. :param text_type public_url: public URL of the service in the region. :param text_type internal_url: internal URL of the service in the region. :param text_type admin_url: administrative URL for the service in the region. :param text_type version_info_url: URL to get the version information of the service. :param text_type version_list_url: URL to get the list of supported versions by the service. :param text_type type_id: service type, e.g object-store :param boolean enabled: whether or not the service is enabled for all users. Services can be disabled for all tenants but still be enabled on a per-tenant basis. :param text_type endpoint_uuid: unique ID for the endpoint within the service. :param text_type tenantid_alias: by default the system uses the text '%tenant_id%' for what to replace in the URLs with the tenantid. This value allows the service adminstrator to use a different textual value. Note: This is not presently used by Mimic which just appends the tenant-id for internally hosted services, and simply uses the URLs as is for externally hosted services. :rtype: :obj:`EndpointTemplateStore` """ return EndpointTemplateStore( id_key=(endpoint_uuid if endpoint_uuid is not None else text_type(uuid.uuid4())), region_key=region, type_key=type_id, name_key=name, enabled_key=enabled, public_url=public_url if public_url is not None else url, internal_url=internal_url if internal_url is not None else url, admin_url=admin_url if admin_url is not None else url, tenant_alias=tenantid_alias, version_id=version, version_info=(version_info_url if version_info_url is not None else url + '/versionInfo'), version_list=(version_list_url if version_list_url is not None else url + '/versions'))
def test_basic_no_dict(self): """ Check the default state where all values should be set to `None`. """ epts = EndpointTemplateStore() self.assertIsNone(epts._template_data) self.assertIsNone(epts.id_key) self.assertIsNone(epts.region_key) self.assertIsNone(epts.type_key) self.assertIsNone(epts.name_key) self.assertIsNone(epts.enabled_key) self.assertIsNone(epts.public_url) self.assertIsNone(epts.internal_url) self.assertIsNone(epts.admin_url) self.assertIsNone(epts.tenant_alias) self.assertIsNone(epts.version_id) self.assertIsNone(epts.version_info) self.assertIsNone(epts.version_list)
def test_serialize_basic(self): """ Serializing the minimal data will result in the correct dict object. """ data = { "id": "some-id", "region": "some-region", "type": "some-type", "name": "some-name" } epts = EndpointTemplateStore() epts.id_key = data['id'] epts.region_key = data['region'] epts.type_key = data['type'] epts.name_key = data['name'] serialized_data = epts.serialize() for k, v in serialized_data.items(): if k not in data: self.assertIsNone(v) else: self.assertEqual(v, data[k])