Skip to content

Commit

Permalink
fixup! fix non consistent ref to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Dec 19, 2024
1 parent 801c378 commit e914620
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lacommunaute/notification/tests/tests_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import httpx
import respx
from django.conf import settings
from django.test import TestCase
from faker import Faker

from config.settings.base import DEFAULT_FROM_EMAIL, SIB_CONTACTS_URL, SIB_SMTP_URL
from lacommunaute.notification.emails import bulk_send_user_to_list, send_email
from lacommunaute.notification.models import EmailSentTrack
from lacommunaute.users.factories import UserFactory
Expand All @@ -17,13 +17,13 @@
class SendEmailTestCase(TestCase):
@classmethod
def setUpTestData(cls):
respx.post(SIB_SMTP_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))
respx.post(settings.SIB_SMTP_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))
cls.to = [{"email": faker.email()}]
cls.params = faker.text()
cls.template_id = faker.random_int()
cls.kind = "first_reply"
cls.payload = {
"sender": {"name": "La Communauté", "email": DEFAULT_FROM_EMAIL},
"sender": {"name": "La Communauté", "email": settings.DEFAULT_FROM_EMAIL},
"to": cls.to,
"params": cls.params,
"templateId": cls.template_id,
Expand Down Expand Up @@ -52,7 +52,7 @@ def test_send_email_with_bcc(self):
class BulkSendUserToListTestCase(TestCase):
@classmethod
def setUpTestData(cls):
respx.post(SIB_CONTACTS_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))
respx.post(settings.SIB_CONTACTS_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))

@respx.mock
def test_bulk_send_user_to_list(self):
Expand Down
17 changes: 5 additions & 12 deletions lacommunaute/notification/tests/tests_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
from django.urls import reverse
from faker import Faker

from config.settings.base import (
DEFAULT_FROM_EMAIL,
SIB_CONTACTS_URL,
SIB_ONBOARDING_LIST,
SIB_SMTP_URL,
SIB_UNANSWERED_QUESTION_TEMPLATE,
)
from lacommunaute.forum_conversation.factories import (
TopicFactory,
)
Expand All @@ -37,7 +30,7 @@
@pytest.fixture(name="mock_respx_post_to_sib_smtp_url")
def mock_respx_post_to_sib_smtp_url_fixture():
with respx.mock:
respx.post(SIB_SMTP_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))
respx.post(settings.SIB_SMTP_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))
yield


Expand Down Expand Up @@ -115,7 +108,7 @@ def test_num_queries(self, db, django_assert_num_queries, mock_respx_post_to_sib
class AddUserToListWhenRegister(TestCase):
def setUp(self):
super().setUp()
respx.post(SIB_CONTACTS_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))
respx.post(settings.SIB_CONTACTS_URL).mock(return_value=httpx.Response(200, json={"message": "OK"}))

@respx.mock
def test_add_user_to_list_when_register(self):
Expand All @@ -128,7 +121,7 @@ def test_add_user_to_list_when_register(self):
],
"emailBlacklist": False,
"smsBlacklist": False,
"listIds": [SIB_ONBOARDING_LIST],
"listIds": [settings.SIB_ONBOARDING_LIST],
"updateExistingContacts": True,
"emptyContactsAttributes": True,
}
Expand Down Expand Up @@ -163,10 +156,10 @@ def payload_for_staff_user_to_notify_on_unanswered_topics_fixture():
)
params = {"count": 1, "link": "".join(url)}
payload = {
"sender": {"name": "La Communauté", "email": DEFAULT_FROM_EMAIL},
"sender": {"name": "La Communauté", "email": settings.DEFAULT_FROM_EMAIL},
"to": to,
"params": params,
"templateId": SIB_UNANSWERED_QUESTION_TEMPLATE,
"templateId": settings.SIB_UNANSWERED_QUESTION_TEMPLATE,
}
yield payload

Expand Down

0 comments on commit e914620

Please sign in to comment.