def test_tenant_normalize_slug_invalid() -> None: empty_slug = " " with raises(TenantCreationError): Tenant._normalize_slug(empty_slug) unsupported_slug = " あ " with raises(TenantCreationError): resp = Tenant._normalize_slug(unsupported_slug)
def directory_file_store_service(tmp_path): config = build_config('DEV')['data'] config['dir_path'] = tmp_path / 'data' standard_tenant_provider = StandardTenantProvider() standard_tenant_provider.setup(Tenant(id='2', name="custom-tenant")) return DirectoryFileStoreService( standard_tenant_provider, config)
def swift_file_store_service(swift_auth_supplier, mock_http_client): data_config = build_config('DEV')['data'] standard_tenant_provider = StandardTenantProvider() standard_tenant_provider.setup(Tenant(id='2', name="custom-tenant")) return SwiftFileStoreService(standard_tenant_provider, swift_auth_supplier, mock_http_client, data_config)
def test_tenant_attributes_from_dict() -> None: tenant_dict = {"id": "farbo007", "name": "Hortofrutícola El Cariño"} tenant = Tenant(**tenant_dict) for key, value in tenant_dict.items(): assert getattr(tenant, key) == value
def memory_repository() -> MemoryRepository: tenant_provider = StandardTenantProvider() tenant_provider.setup(Tenant(id='001', name="Default")) auth_provider = StandardAuthProvider() auth_provider.setup(User(id='001', name='johndoe')) parser = QueryParser() repository: MemoryRepository = MemoryRepository(parser, tenant_provider, auth_provider) repository.load({"default": {}}) return repository
def sql_repository(connection_manager, dummies_table) -> SqlRepository: parser = SqlParser(SafeEval()) tenant_provider = StandardTenantProvider() tenant_provider.setup(Tenant(id="001", name="Origin")) auth_provider = StandardAuthProvider() auth_provider.setup(User(id='001', name='johndoe')) sql_repository: SqlRepository = SqlRepository( table=dummies_table, constructor=DummyEntity, tenant_provider=tenant_provider, auth_provider=auth_provider, connection_manager=connection_manager, parser=parser) return sql_repository
def tenant() -> Tenant: return Tenant(id='001', name="Amazon")
def test_tenant_normalize_slug() -> None: given_slug = "Hortofrutícola El Cariño" slug = Tenant._normalize_slug(given_slug) assert slug == 'hortofruticola_el_carino'
def tenant_provider(): tenant_provider = StandardTenantProvider() tenant_provider.setup(Tenant(id="001", name="Origin")) return tenant_provider
def tenant_provider(): tenant_provider = StandardTenantProvider() tenant_provider.setup(Tenant(id='001', name="default")) return tenant_provider