From 27d59048de91162f85f65847cd17e1a4ad16b3ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Reuiller?= Date: Mon, 16 Dec 2024 11:11:27 +0100 Subject: [PATCH] fix(EmailGroupFactory): flush EmailGroup manualy before to prevent duplicate key errors --- lemarche/conversations/tests.py | 2 ++ lemarche/www/dashboard_siaes/tests.py | 2 ++ lemarche/www/tenders/tests.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/lemarche/conversations/tests.py b/lemarche/conversations/tests.py index cf9435b1e..70d46ae3d 100644 --- a/lemarche/conversations/tests.py +++ b/lemarche/conversations/tests.py @@ -104,6 +104,8 @@ def test_get_template_id(self): class TemplateTransactionalModelSaveTest(TransactionTestCase): + reset_sequences = True + @classmethod def setUpTestData(cls): pass diff --git a/lemarche/www/dashboard_siaes/tests.py b/lemarche/www/dashboard_siaes/tests.py index 4346c968e..4ab20ee47 100644 --- a/lemarche/www/dashboard_siaes/tests.py +++ b/lemarche/www/dashboard_siaes/tests.py @@ -2,6 +2,7 @@ from django.urls import reverse from lemarche.conversations.factories import TemplateTransactionalFactory +from lemarche.conversations.models import EmailGroup from lemarche.perimeters.factories import PerimeterFactory from lemarche.perimeters.models import Perimeter from lemarche.sectors.factories import SectorFactory, SectorGroupFactory @@ -23,6 +24,7 @@ def setUpTestData(cls): cls.siae_with_user = SiaeFactory() cls.siae_with_user.users.add(cls.user_siae) cls.siae_without_user = SiaeFactory() + EmailGroup.objects.all().delete() # to avoid duplicate key error TemplateTransactionalFactory(code="SIAEUSERREQUEST_ASSIGNEE") def test_anonymous_user_cannot_adopt_siae(self): diff --git a/lemarche/www/tenders/tests.py b/lemarche/www/tenders/tests.py index 4dc73a6cc..023be5728 100644 --- a/lemarche/www/tenders/tests.py +++ b/lemarche/www/tenders/tests.py @@ -11,6 +11,7 @@ from sesame.utils import get_query_string as sesame_get_query_string from lemarche.conversations.factories import TemplateTransactionalFactory +from lemarche.conversations.models import EmailGroup from lemarche.perimeters.factories import PerimeterFactory from lemarche.perimeters.models import Perimeter from lemarche.sectors.factories import SectorFactory @@ -1133,6 +1134,7 @@ def setUpTestData(cls): cls.tender_contact_click_stat_url = reverse( "tenders:detail-contact-click-stat", kwargs={"slug": cls.tender.slug} ) + EmailGroup.objects.all().delete() # to avoid duplicate key error TemplateTransactionalFactory(code="TENDERS_AUTHOR_SIAE_INTERESTED_1") def test_anonymous_user_cannot_notify_interested(self):