Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/users/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ def send_verification_code(email: str) -> None:
},
)

email_multi_alternative = EmailMultiAlternatives(
email_message = EmailMultiAlternatives(
subject=f"Jusicool 메일 인증 코드",
body=html_content,
to=[email],
from_email=settings.EMAIL_HOST_USER,
)
email_multi_alternative.attach_alternative(
email_message.attach_alternative(
html_content,
"text/html",
)
email_multi_alternative.send()
email_message.send()
10 changes: 5 additions & 5 deletions apps/users/tests/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import pytest

from apps.users.factories import UserFactory
from apps.users.services import UserVerificationService
from apps.users.services import EmailVerificationService


@pytest.mark.django_db
class TestUserVerificationService:
class TestEmailVerificationService:

@pytest.fixture(autouse=True)
def mock_exist_user(self) -> UserFactory:
Expand All @@ -16,15 +16,15 @@ def mock_exist_user(self) -> UserFactory:
is_active=True,
)

@patch("apps.users.services.send_email_verify_code.delay")
def test_send_verification_code(
@patch("apps.users.services.send_verification_code.delay")
def test_send_verification_email(
self,
mock_task,
):
"""메일 전송 task를 호출한다."""

# Action
UserVerificationService().send_verification_code(email="[email protected]")
EmailVerificationService().send_verification_email(email="[email protected]")

# Assert
mock_task.assert_called_once_with(email="[email protected]")
8 changes: 4 additions & 4 deletions apps/users/tests/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from unittest.mock import patch

from apps.users.tasks import send_email_verify_code
from apps.users.tasks import send_verification_code
from core.cache.prefix import CacheKeyPrefix


class TestSendEmailVerifyCode:
class TestSendVerificationCode:

@patch("apps.users.tasks.Cache.set")
@patch("apps.users.tasks.random.randint")
def test_send_email_verify_code(
def test_send_verification_code(
self,
mock_randint,
mock_cache_set,
Expand All @@ -21,7 +21,7 @@ def test_send_email_verify_code(
mock_randint.return_value = mock_code

# Action
send_email_verify_code(user_email=user_email)
send_verification_code(email=user_email)

# Assert
mock_cache_set.assert_called_once_with(
Expand Down