From e914620c364fae33d712a56d68e2a1d9253c5f8e Mon Sep 17 00:00:00 2001 From: vincent porte Date: Thu, 19 Dec 2024 11:24:58 +0100 Subject: [PATCH] fixup! fix non consistent ref to settings --- lacommunaute/notification/tests/tests_emails.py | 8 ++++---- lacommunaute/notification/tests/tests_tasks.py | 17 +++++------------ 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/lacommunaute/notification/tests/tests_emails.py b/lacommunaute/notification/tests/tests_emails.py index fc058476..ea9c52cc 100644 --- a/lacommunaute/notification/tests/tests_emails.py +++ b/lacommunaute/notification/tests/tests_emails.py @@ -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 @@ -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, @@ -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): diff --git a/lacommunaute/notification/tests/tests_tasks.py b/lacommunaute/notification/tests/tests_tasks.py index 3ddee86d..24ed8429 100644 --- a/lacommunaute/notification/tests/tests_tasks.py +++ b/lacommunaute/notification/tests/tests_tasks.py @@ -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, ) @@ -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 @@ -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): @@ -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, } @@ -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