From b16386fdd388d81828460eea62dbe8c0ad19624c Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 21 Feb 2024 12:39:49 +0100 Subject: [PATCH] fix tests --- lemarche/www/tenders/tests.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lemarche/www/tenders/tests.py b/lemarche/www/tenders/tests.py index 4ec6ba13a..b959baa90 100644 --- a/lemarche/www/tenders/tests.py +++ b/lemarche/www/tenders/tests.py @@ -681,6 +681,10 @@ def setUpTestData(cls): detail_not_interested_click_date=timezone.now(), ) + @classmethod + def get_closed_verbatim(cls, tender: Tender): + return f"{tender.get_kind_display()} clôturé le {tender.deadline_date.strftime('%d %B %Y')}" + def test_anyone_can_view_sent_tenders(self): for tender in Tender.objects.all(): # anonymous user @@ -810,12 +814,12 @@ def test_tender_deadline_date_display(self): # tender is not outdated by default url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug}) response = self.client.get(url) - self.assertNotContains(response, "Clôturé") + self.assertNotContains(response, self.get_closed_verbatim(tender=self.tender_1)) # new tender with outdated deadline_date tender_2 = TenderFactory(deadline_date=timezone.now() - timedelta(days=1)) url = reverse("tenders:detail", kwargs={"slug": tender_2.slug}) response = self.client.get(url) - self.assertContains(response, "Clôturé") + self.assertContains(response, self.get_closed_verbatim(tender=tender_2)) def test_tender_author_has_additional_stats(self): self.client.force_login(self.user_buyer_1) @@ -849,7 +853,7 @@ def test_tender_contact_display(self): # anonymous user url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug}) response = self.client.get(url) - self.assertNotContains(response, "Clôturé") + self.assertNotContains(response, self.get_closed_verbatim(tender=self.tender_1)) self.assertContains(response, "Cet appel d'offres vous intéresse ?") self.assertContains(response, "Répondre en co-traitance ?") self.assertContains(response, "Cette demande ne vous intéresse pas ?") @@ -908,7 +912,7 @@ def test_tender_response_is_anonymous_contact_display(self): # anonymous user url = reverse("tenders:detail", kwargs={"slug": self.tender_3_response_is_anonymous.slug}) response = self.client.get(url) - self.assertNotContains(response, "Clôturé") + self.assertNotContains(response, self.get_closed_verbatim(tender=self.tender_3_response_is_anonymous)) self.assertContains(response, "Cet appel d'offres vous intéresse ?") self.assertContains(response, "Répondre en co-traitance ?") self.assertContains(response, "Cette demande ne vous intéresse pas ?") @@ -970,33 +974,33 @@ def test_tender_outdated_contact_display(self): # anonymous user url = reverse("tenders:detail", kwargs={"slug": tender_2.slug}) response = self.client.get(url) - self.assertContains(response, "Clôturé") + self.assertContains(response, self.get_closed_verbatim(tender=tender_2)) self.assertNotContains(response, "Répondre à cette opportunité") # siae user interested self.client.force_login(self.siae_user_1) url = reverse("tenders:detail", kwargs={"slug": tender_2.slug}) response = self.client.get(url) - self.assertContains(response, "Clôturé") + self.assertContains(response, self.get_closed_verbatim(tender=tender_2)) self.assertNotContains(response, "Contactez le client dès maintenant") self.assertNotContains(response, "Répondre à cette opportunité") # siae user not concerned self.client.force_login(self.siae_user_6) url = reverse("tenders:detail", kwargs={"slug": tender_2.slug}) response = self.client.get(url) - self.assertContains(response, "Clôturé") + self.assertContains(response, self.get_closed_verbatim(tender=tender_2)) self.assertNotContains(response, "Répondre à cette opportunité") # siae user without siae self.client.force_login(self.siae_user_without_siae) url = reverse("tenders:detail", kwargs={"slug": tender_2.slug}) response = self.client.get(url) - self.assertContains(response, "Clôturé") + self.assertContains(response, self.get_closed_verbatim(tender=tender_2)) self.assertNotContains(response, "veuillez d'abord vous") self.assertNotContains(response, "Répondre à cette opportunité") # author self.client.force_login(self.user_buyer_1) url = reverse("tenders:detail", kwargs={"slug": tender_2.slug}) response = self.client.get(url) - self.assertContains(response, "Clôturé") + self.assertContains(response, self.get_closed_verbatim(tender=tender_2)) self.assertContains(response, "Coordonnées") self.assertNotContains(response, "Contactez le client dès maintenant") self.assertNotContains(response, "Répondre à cette opportunité")