Coverage for src/tests/modules/identity/test_enact_user.py: 100%
22 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
1"""Module for testing the use case Enact User."""
3import pytest
5from kwai_bc_identity.enact_user import EnactUser, EnactUserCommand
6from kwai_bc_identity.users.user_account import UserAccountEntity
7from kwai_bc_identity.users.user_account_db_repository import (
8 UserAccountDbRepository,
9)
10from kwai_core.db.database import Database
11from kwai_core.domain.presenter import Presenter
14pytestmark = pytest.mark.db
17class DummyPresenter(Presenter[UserAccountEntity]):
18 """A dummy presenter for testing EnactUser."""
20 def __init__(self):
21 self._entity = None
23 def present(self, use_case_result: UserAccountEntity) -> None:
24 self._entity = use_case_result
26 @property
27 def entity(self) -> UserAccountEntity:
28 """Return the entity returned by the use case."""
29 return self._entity
32async def test_enact_user(database: Database, make_user_account_in_db):
33 """Test the revoke user use case."""
34 user_account_in_db = await make_user_account_in_db()
36 user_account_repo = UserAccountDbRepository(database)
37 command = EnactUserCommand(uuid=str(user_account_in_db.user.uuid))
38 presenter = DummyPresenter()
40 await EnactUser(user_account_repo, presenter).execute(command)
42 assert presenter.entity.revoked is False, "The user account should be active"