async def test_services(self, sequoia_client, response_registry_list_services, response_identity_get_oauth_token): responses = [ # Services discovery response_registry_list_services, # Auth token response_identity_get_oauth_token, ] with patch.object(httpx.AsyncClient, "request", new_callable=AsyncMock, side_effect=responses): async with sequoia_client as client: assert client.services() == { "identity": Service( name="identity", url="https://identity.sequoia.piksel.com", title="Identity and Access Service", description="Responsible for identity and access management", ), "metadata": Service( name="metadata", url="https://metadata.sequoia.piksel.com", title="Metadata Service", description="Stores content metadata resources", ), "registry": Service( name="registry", url="https://registry.sequoia.piksel.com", title="Registry Service", description="Responsible for managing the service registry", ), }
async def test_set_owner( self, sequoia_client, response_registry_list_services, response_registry_get_description, response_identity_get_description, response_metadata_get_description, ): responses = [ # Get services and description of them after setting owner response_registry_list_services, response_identity_get_description, response_metadata_get_description, response_registry_get_description, ] with patch.object(httpx.AsyncClient, "request", new_callable=AsyncMock, side_effect=responses): assert sequoia_client._token is None assert sequoia_client._owner is None assert sequoia_client._services == ServicesRegistry() await sequoia_client.set_owner("root") assert sequoia_client._token is None assert sequoia_client._owner == "root" assert sequoia_client._services == ServicesRegistry({ "identity": Service( name="identity", url="https://identity.sequoia.piksel.com", title="Identity and Access Service", description= "Responsible for identity and access management", ), "metadata": Service( name="metadata", url="https://metadata.sequoia.piksel.com", title="Metadata Service", description="Stores content metadata resources", ), "registry": Service( name="registry", url="https://registry.sequoia.piksel.com", title="Registry Service", description="Responsible for managing the service registry", ), })
async def test_build_request(self, request_builder): # Build request builder = request_builder.foo.bar # Asserts assert builder._owner is None assert builder._token is None assert builder._service == Service(name="foo", url="https://foo") assert await builder._resource == Resource(name="bar", path="/bar")
def service(resources_registry): s = Service(name="foo", url="https://foo") s._resources = resources_registry return s