def _given_auth_token_headers_creator( type_token=str, client_id: ClientId = ClientId("client-id"), user_id: UserId = None, ): headers = { "Authorization": f"Bearer {JwtTokenBuilder.build(given_dummy_key, type_token, client_id, user_id=user_id)}" } return headers
def test_should_inherit_from_repository_and_configure_one_with_client_id(): class Repository(IRepository): pass repository = Repository() assert not hasattr(repository, "client_id") repository_with_client_id = repository.with_client_id(ClientId("acme")) assert hasattr(repository_with_client_id, "client_id") assert repository_with_client_id is not repository
def test_should_inherit_from_repository_and_configure_one_with_client_id_getting_client_id( ): class Repository(IRepository): pass repository = Repository() repository_with_client_id = repository.with_client_id(ClientId("acme")) client_id = repository_with_client_id.get_client_id() assert isinstance(client_id, ClientId) client_id_value = repository_with_client_id.get_client_id_value() assert isinstance(client_id_value, str)
def test_should_inherit_from_pattern_base_and_extend_it_with_client_id(): class MyRepository(PatternBase): pass repository = MyRepository() client_id = ClientId("client-id") repository_with_client_id = repository.with_client_id(client_id) assert isinstance(repository_with_client_id, MyRepository) assert isinstance(repository_with_client_id.get_client_id(), ClientId) assert isinstance(repository_with_client_id.get_client_id_value(), str) assert repository_with_client_id.get_client_id() == client_id
def test_should_inherit_from_pattern_base_and_extend_it_with_info_id(): class MyRepository(PatternBase): pass repository = MyRepository() client_id = ClientId("client-id") user_id = UserId.generate() info_id = InfoId(client_id, user_id) repository_with_info_id_id = repository.with_info_id(info_id) assert isinstance(repository_with_info_id_id, MyRepository) assert isinstance(repository_with_info_id_id.get_client_id(), ClientId) assert isinstance(repository_with_info_id_id.get_client_id_value(), str) assert repository_with_info_id_id.get_client_id() == client_id assert isinstance(repository_with_info_id_id.get_user_id(), UserId) assert isinstance(repository_with_info_id_id.get_user_id_value(), str) assert repository_with_info_id_id.get_user_id() == user_id assert isinstance(repository_with_info_id_id.get_info_id(), InfoId) assert repository_with_info_id_id.get_info_id() == info_id
def from_dict(kdict: dict): return Client(ClientId(kdict.get("client_id")), kdict.get("name"))
def random(): return Client(ClientId("ACME"), "ACME")
def user(database_name: str): MyClientSqlRepository(database_name).save(Client.random()) return MyUserSqlRepository(database_name).with_client_id( ClientId("ACME"))