-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e39d1b
commit 0a8cdd1
Showing
15 changed files
with
165 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from typing import Any | ||
|
||
import pytest | ||
|
||
from apps.logs.domain.constants import UserActivityEvent, UserActivityEventType | ||
from infrastructure.http.domain import MindloggerContentSource | ||
|
||
|
||
@pytest.fixture | ||
def base_log_data() -> dict[str, Any]: | ||
return { | ||
"firebase_token_id": None, | ||
"event": UserActivityEvent.LOGIN, | ||
"event_type": UserActivityEventType.LOGIN, | ||
"user_agent": "test", | ||
"mindlogger_content": MindloggerContentSource.undefined, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Any | ||
|
||
from sqlalchemy.ext.asyncio import AsyncSession | ||
|
||
from apps.logs.services import UserActivityLogService | ||
from apps.users.db.schemas import UserSchema | ||
from infrastructure.http.domain import MindloggerContentSource | ||
|
||
|
||
async def test_create_log_success( | ||
session: AsyncSession, user_tom: UserSchema, base_log_data: dict[str, Any] | ||
) -> None: | ||
base_log_data["user_id"] = user_tom.id | ||
log = await UserActivityLogService(session).create_log(**base_log_data) | ||
assert log.user_id == user_tom.id | ||
|
||
|
||
async def test_create_log_undefined_with_device_is_mobile_content( | ||
session: AsyncSession, user_tom: UserSchema, base_log_data: dict[str, Any] | ||
) -> None: | ||
base_log_data["user_id"] = user_tom.id | ||
base_log_data["firebase_token_id"] = "token" | ||
base_log_data["mindlogger_content"] = MindloggerContentSource.undefined | ||
log = await UserActivityLogService(session).create_log(**base_log_data) | ||
assert log.mindlogger_content == MindloggerContentSource.mobile |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from typing import AsyncGenerator | ||
|
||
import pytest | ||
from sqlalchemy.ext.asyncio import AsyncSession | ||
|
||
from apps.authentication.services import AuthenticationService | ||
from apps.shared.hashing import hash_sha224 | ||
from apps.users.cruds.user import UsersCRUD | ||
from apps.users.db.schemas import UserSchema | ||
from apps.users.domain import UserCreateRequest | ||
|
||
|
||
@pytest.fixture | ||
def user_tom_create() -> UserCreateRequest: | ||
# Use tom data for replacing json fixtures with pytest fixtures | ||
# without failing tests | ||
return UserCreateRequest( | ||
email="[email protected]", | ||
password="Test1234!", | ||
first_name="Tom", | ||
last_name="Isaak", | ||
) | ||
|
||
|
||
@pytest.fixture | ||
async def user_tom( | ||
user_tom_create: UserCreateRequest, session: AsyncSession | ||
) -> AsyncGenerator: | ||
email_hash = hash_sha224(user_tom_create.email) | ||
hashed_password = AuthenticationService.get_password_hash( | ||
user_tom_create.password | ||
) | ||
user = await UsersCRUD(session).save( | ||
UserSchema( | ||
email=email_hash, | ||
email_encrypted=user_tom_create.email, | ||
first_name=user_tom_create.first_name, | ||
last_name=user_tom_create.last_name, | ||
hashed_password=hashed_password, | ||
) | ||
) | ||
yield user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters