Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
fix: try to fix pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Smirnov committed Sep 16, 2023
1 parent f8f5bb9 commit e07740b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 70 deletions.
4 changes: 2 additions & 2 deletions tests/test_server/test_apps/test_identity/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def reg_data(registration_data_factory) -> RegistrationData:
def expected_user_data(reg_data: RegistrationData) -> dict[str, Any]:
"""Fixture that return exeected user data."""
return {
key: value_name for key, value_name
in reg_data.items()
key: value_name
for key, value_name in reg_data.items()
if not key.startswith('password')
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,37 @@
from tests.plugins.identity.user import RegistrationData, UserAssertion


class TestLeadCreate:
"""Test class for testing LeadCreate service."""
@pytest.mark.django_db()
def test_success_lead_create(
user: User,
reg_data: RegistrationData,
expected_user_data: dict[str, Any],
assert_correct_user: UserAssertion,
settings: Settings,
) -> None:
"""Testing service that create lead user."""
assert_correct_user(reg_data['email'], expected_user_data)
actual_id = 11
actual_response = UserResponse(id=actual_id)
expected_id = LeadCreate(
api_timeout=settings.PLACEHOLDER_API_TIMEOUT,
api_url=settings.PLACEHOLDER_API_URL,
)(user=user)
assert actual_response.id == expected_id

@pytest.mark.django_db()
def test_success_lead_create(
self,
user: User,
reg_data: RegistrationData,
expected_user_data: dict[str, Any],
assert_correct_user: UserAssertion,
settings: Settings,
) -> None:
"""Testing service that create lead user."""
assert_correct_user(reg_data['email'], expected_user_data)
actual_id = 11
actual_response = UserResponse(id=actual_id)
expected_id = LeadCreate(
api_timeout=settings.PLACEHOLDER_API_TIMEOUT,
api_url=settings.PLACEHOLDER_API_URL,
)(user=user)
assert actual_response.id == expected_id

def test_success_url_path(self, settings: Settings) -> None:
"""Testing method that create URL path for the request."""
expected_url_path = 'https://jsonplaceholder.typicode.com/users'
fetcher = LeadCreate(
api_timeout=settings.PLACEHOLDER_API_TIMEOUT,
api_url=settings.PLACEHOLDER_API_URL,
)
actual_url_path = fetcher.url_path()
assert actual_url_path == expected_url_path
def test_success_url_path(settings: Settings) -> None:
"""Testing method that create URL path for the request."""
expected_url_path = 'https://jsonplaceholder.typicode.com/users'
fetcher = LeadCreate(
api_timeout=settings.PLACEHOLDER_API_TIMEOUT,
api_url=settings.PLACEHOLDER_API_URL,
)
actual_url_path = fetcher.url_path()
assert actual_url_path == expected_url_path


@pytest.mark.django_db
@pytest.mark.django_db()
def test_success_lead_update(
user: User,
reg_data: RegistrationData,
Expand All @@ -73,8 +70,8 @@ def test_success_validate_user_response() -> None:
def test_failed_validate_user_response() -> None:
"""Testing UserResponse model, failed case."""
with pytest.raises(ValidationError) as exc:
UserResponse.model_validate({'TEST': 1}).id
assert exc.typename == 'ValidationError'
id_ = UserResponse.model_validate({'TEST': 1}).id
assert 'ValidationError' in exc.typename


@pytest.mark.django_db()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,38 @@
from tests.plugins.identity.user import RegistrationData, UserAssertion


class TestUserCreateNew:
"""Test class for testing UserCreateNew service."""
@pytest.mark.django_db()
def test_success_create_new_user(
user: User,
settings: Settings,
assert_correct_user: UserAssertion,
reg_data: RegistrationData,
expected_user_data: dict[str, Any],
) -> None:
"""Testing usecase that create new user."""
not_lead_user = User.objects.get(email=reg_data['email'])
assert not_lead_user.lead_id is None
assert_correct_user(reg_data['email'], expected_user_data)

@pytest.mark.django_db()
def test_success_create_new_user(
self,
user: User,
settings: Settings,
assert_correct_user: UserAssertion,
reg_data: RegistrationData,
expected_user_data: dict[str, Any],
) -> None:
"""Testing usecase that create new user."""
not_lead_user = User.objects.get(email=reg_data['email'])
assert not_lead_user.lead_id is None
assert_correct_user(reg_data['email'], expected_user_data)
UserCreateNew(settings=settings)(user=user)
lead_user = User.objects.get(email=reg_data['email'])
expected_lead_id = 11
assert lead_user.lead_id == expected_lead_id

UserCreateNew(settings=settings)(user=user)
lead_user = User.objects.get(email=reg_data['email'])
expected_lead_id = 11
assert lead_user.lead_id == expected_lead_id

@pytest.mark.django_db()
def test_success_update_user_ids(
self,
user: User,
settings: Settings,
assert_correct_user: UserAssertion,
reg_data: RegistrationData,
expected_user_data: dict[str, Any],
) -> None:
"""Testing usecase that update user id."""
assert_correct_user(reg_data['email'], expected_user_data)
response = UserResponse(id=100)
UserCreateNew(settings=settings)._update_user_ids(
user=user, response=response,
)
actual_user = User.objects.get(email=reg_data['email'])
assert actual_user.lead_id == response.id
@pytest.mark.django_db()
def test_success_update_user_ids(
user: User,
settings: Settings,
assert_correct_user: UserAssertion,
reg_data: RegistrationData,
expected_user_data: dict[str, Any],
) -> None:
"""Testing usecase that update user id."""
assert_correct_user(reg_data['email'], expected_user_data)
response = UserResponse(id=100)
UserCreateNew(settings=settings)._update_user_ids(
user=user, response=response,
)
actual_user = User.objects.get(email=reg_data['email'])
assert actual_user.lead_id == response.id

0 comments on commit e07740b

Please sign in to comment.