Coverage for src/tests/modules/identity/test_create_user.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2024-01-01 00:00 +0000

1"""Test the use case 'create user'.""" 

2 

3import pytest 

4 

5from kwai_bc_identity.create_user import CreateUser, CreateUserCommand 

6from kwai_bc_identity.users.user_account_db_repository import ( 

7 UserAccountDbRepository, 

8) 

9from kwai_core.db.database import Database 

10 

11 

12pytestmark = pytest.mark.db 

13 

14 

15async def test_create_user(database: Database): 

16 """Test the use case CreateUser.""" 

17 user_account_repo = UserAccountDbRepository(database) 

18 command = CreateUserCommand( 

19 email="ichiro.abe@kwai.com", 

20 first_name="Ichiro", 

21 last_name="Abe", 

22 password="Test/1234", 

23 remark="Created with pytest 'test_create_user'", 

24 ) 

25 user_account = await CreateUser(user_account_repo).execute(command) 

26 assert user_account is not None, "There should be a user account" 

27 

28 # Cleanup: delete the user account 

29 await user_account_repo.delete(user_account)