Skip to content

Commit

Permalink
add tests to cocontracting visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Sep 19, 2023
1 parent 85abdf2 commit d79eb77
Showing 1 changed file with 67 additions and 1 deletion.
68 changes: 67 additions & 1 deletion lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,43 @@ def test_tender_contact_details_display(self):
self.assertNotContains(response, "Voir l'appel d'offres")
self.assertContains(response, "Lien partagé")

def test_tender_cocontracting_display(self):
# anonymous
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
self.assertNotContains(response, "Répondre en co-traitance ?")

class TenderDetailContactClickStatViewViewTest(TestCase):
# siae user interested but has a detail_contact_click_date
self.client.force_login(self.siae_user_1)
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
self.assertNotContains(response, "Répondre en co-traitance ?")
# siae user not concerned
self.client.force_login(self.siae_user_2)
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
self.assertContains(response, "Répondre en co-traitance ?")
# siae user interested
cls.tendersiae_1_2 = TenderSiae.objects.create(
tender=self.tender_1, siae=self.siae_2, email_send_date=timezone.now()
)
self.client.force_login(self.siae_user_2)
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
self.assertContains(response, "Répondre en co-traitance ?")
# siae user without siae
self.client.force_login(self.siae_user_3)
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
self.assertNotContains(response, "Répondre en co-traitance ?")
# author
self.client.force_login(self.user_buyer_1)
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
self.assertNotContains(response, "Répondre en co-traitance ?")


class TenderDetailContactClickStatViewTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.siae = SiaeFactory(name="ZZ ESI")
Expand Down Expand Up @@ -962,6 +997,37 @@ def test_update_tendersiae_stats_on_tender_contact_click_with_siae_id_param(self
)


class TenderDetailCocontractingClickView(TestCase):
@classmethod
def setUpTestData(cls):
cls.siae = SiaeFactory(name="ZZ ESI")
cls.siae_user = UserFactory(kind=User.KIND_SIAE, siaes=[cls.siae])
cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer")
cls.tender = TenderFactory(
kind=tender_constants.KIND_TENDER,
author=cls.user_buyer,
amount=tender_constants.AMOUNT_RANGE_100_150,
accept_share_amount=True,
response_kind=[Tender.RESPONSE_KIND_EMAIL],
)
cls.tendersiae = TenderSiae.objects.create(
tender=cls.tender,
siae=cls.siae,
source="EMAIL",
email_send_date=timezone.now(),
email_link_click_date=timezone.now(),
detail_display_date=timezone.now(),
detail_contact_click_date=timezone.now(),
)
TenderQuestionFactory(tender=cls.tender)

def test_user_can_notify_cocontracting_wish(self):
url = reverse("tenders:detail-cocontracting-click", kwargs={"slug": self.tender.slug})
self.client.force_login(self.siae_user)
response = self.client.post(url, data={})
self.assertContains(response, "Nous avons bien pris en compte votre demande de mise en relation")


# TODO: this test doesn't work anymore. find a way to test logging post-email in non-prod environments?
# class TenderTasksTest(TestCase):
# @classmethod
Expand Down

0 comments on commit d79eb77

Please sign in to comment.