diff --git a/lemarche/conversations/tests.py b/lemarche/conversations/tests.py index cf9435b1e..4215d6fd6 100644 --- a/lemarche/conversations/tests.py +++ b/lemarche/conversations/tests.py @@ -6,7 +6,7 @@ from django.utils import timezone from lemarche.conversations import constants as conversation_constants -from lemarche.conversations.factories import ConversationFactory, TemplateTransactionalFactory +from lemarche.conversations.factories import ConversationFactory, EmailGroupFactory, TemplateTransactionalFactory from lemarche.conversations.models import Conversation, TemplateTransactional from lemarche.siaes.factories import SiaeFactory @@ -105,22 +105,31 @@ def test_get_template_id(self): class TemplateTransactionalModelSaveTest(TransactionTestCase): @classmethod - def setUpTestData(cls): - pass + def setUp(cls): + cls.email_group = EmailGroupFactory() def test_template_transactional_field_rules(self): - self.assertRaises(IntegrityError, TemplateTransactionalFactory, source=None) + self.assertRaises(IntegrityError, TemplateTransactionalFactory, group=self.email_group, source=None) def test_template_transactional_validation_on_save(self): TemplateTransactionalFactory( - mailjet_id=None, brevo_id=None, source=conversation_constants.SOURCE_BREVO, is_active=False + group=self.email_group, + mailjet_id=None, + brevo_id=None, + source=conversation_constants.SOURCE_BREVO, + is_active=False, ) TemplateTransactionalFactory( - mailjet_id=None, brevo_id=123, source=conversation_constants.SOURCE_BREVO, is_active=True + group=self.email_group, + mailjet_id=None, + brevo_id=123, + source=conversation_constants.SOURCE_BREVO, + is_active=True, ) self.assertRaises( ValidationError, TemplateTransactionalFactory, + group=self.email_group, mailjet_id=123, brevo_id=None, source=conversation_constants.SOURCE_BREVO, @@ -129,6 +138,7 @@ def test_template_transactional_validation_on_save(self): self.assertRaises( ValidationError, TemplateTransactionalFactory, + group=self.email_group, mailjet_id=None, brevo_id=123, source=conversation_constants.SOURCE_MAILJET, diff --git a/lemarche/www/dashboard_siaes/tests.py b/lemarche/www/dashboard_siaes/tests.py index 4346c968e..98ec3d5fe 100644 --- a/lemarche/www/dashboard_siaes/tests.py +++ b/lemarche/www/dashboard_siaes/tests.py @@ -1,7 +1,7 @@ from django.test import TestCase from django.urls import reverse -from lemarche.conversations.factories import TemplateTransactionalFactory +from lemarche.conversations.factories import EmailGroupFactory, TemplateTransactionalFactory from lemarche.perimeters.factories import PerimeterFactory from lemarche.perimeters.models import Perimeter from lemarche.sectors.factories import SectorFactory, SectorGroupFactory @@ -23,7 +23,8 @@ def setUpTestData(cls): cls.siae_with_user = SiaeFactory() cls.siae_with_user.users.add(cls.user_siae) cls.siae_without_user = SiaeFactory() - TemplateTransactionalFactory(code="SIAEUSERREQUEST_ASSIGNEE") + group = EmailGroupFactory() + TemplateTransactionalFactory(code="SIAEUSERREQUEST_ASSIGNEE", group=group) def test_anonymous_user_cannot_adopt_siae(self): url = reverse("dashboard_siaes:siae_search_by_siret") diff --git a/lemarche/www/tenders/tests.py b/lemarche/www/tenders/tests.py index 4dc73a6cc..8675b669f 100644 --- a/lemarche/www/tenders/tests.py +++ b/lemarche/www/tenders/tests.py @@ -10,7 +10,7 @@ from django.utils import timezone from sesame.utils import get_query_string as sesame_get_query_string -from lemarche.conversations.factories import TemplateTransactionalFactory +from lemarche.conversations.factories import EmailGroupFactory, TemplateTransactionalFactory from lemarche.perimeters.factories import PerimeterFactory from lemarche.perimeters.models import Perimeter from lemarche.sectors.factories import SectorFactory @@ -1133,7 +1133,8 @@ def setUpTestData(cls): cls.tender_contact_click_stat_url = reverse( "tenders:detail-contact-click-stat", kwargs={"slug": cls.tender.slug} ) - TemplateTransactionalFactory(code="TENDERS_AUTHOR_SIAE_INTERESTED_1") + group = EmailGroupFactory() + TemplateTransactionalFactory(code="TENDERS_AUTHOR_SIAE_INTERESTED_1", group=group) def test_anonymous_user_cannot_notify_interested(self): response = self.client.get(self.tender_detail_url)