From ef79d1e349ef6006bfff3f88a7ab686e6c1390f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Reuiller?= Date: Mon, 18 Dec 2023 18:23:51 +0100 Subject: [PATCH] change wording in confirm and error message --- .../_detail_cocontracting_click_confirm.html | 3 +- .../_detail_cocontracting_click_error.html | 2 +- lemarche/www/tenders/tests.py | 28 +++++++++++++++---- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lemarche/templates/tenders/_detail_cocontracting_click_confirm.html b/lemarche/templates/tenders/_detail_cocontracting_click_confirm.html index e7fbcba4f..9ae834e94 100644 --- a/lemarche/templates/tenders/_detail_cocontracting_click_confirm.html +++ b/lemarche/templates/tenders/_detail_cocontracting_click_confirm.html @@ -1,6 +1,5 @@ diff --git a/lemarche/templates/tenders/_detail_cocontracting_click_error.html b/lemarche/templates/tenders/_detail_cocontracting_click_error.html index 9e6b60975..43cca1821 100644 --- a/lemarche/templates/tenders/_detail_cocontracting_click_error.html +++ b/lemarche/templates/tenders/_detail_cocontracting_click_error.html @@ -1,5 +1,5 @@ diff --git a/lemarche/www/tenders/tests.py b/lemarche/www/tenders/tests.py index 2bef90775..8a5cd0520 100644 --- a/lemarche/www/tenders/tests.py +++ b/lemarche/www/tenders/tests.py @@ -1226,7 +1226,7 @@ def setUpTestData(self): ) TenderQuestionFactory(tender=self.tender) - def test_user_can_notify_cocontracting_wish(self): + def test_user_can_notify_cocontracting_wish_with_siae_id(self): url = reverse("tenders:detail-cocontracting-click", kwargs={"slug": self.tender.slug}) with mock.patch("lemarche.www.tenders.tasks.send_mail_async") as mock_send_mail_async: response = self.client.post(url, data={}) @@ -1235,29 +1235,47 @@ def test_user_can_notify_cocontracting_wish(self): with mock.patch("lemarche.www.tenders.tasks.send_mail_async") as mock_send_mail_async: response = self.client.post(f"{url}?siae_id=999999", data={}) - self.assertContains(response, "nous n'avons pas pu prendre en compte votre demande de mise en relation") + self.assertContains( + response, "nous n'avons pas pu prendre en compte votre souhait de répondre en co-traitance" + ) mock_send_mail_async.assert_not_called() + self.assertEqual( + TenderSiae.objects.get(tender=self.tender, siae=self.siae).detail_cocontracting_click_date, None + ) with mock.patch("lemarche.www.tenders.tasks.send_mail_async") as mock_send_mail_async: response = self.client.post(f"{url}?siae_id={self.siae.id}", data={}) - self.assertContains(response, "Nous avons bien pris en compte votre demande de mise en relation") + self.assertContains(response, "Votre intérêt a bien été signalé au client.") mock_send_mail_async.assert_called_once() email_body = mock_send_mail_async.call_args[1]["email_body"] self.assertTrue(f"La structure {self.siae.name } souhaite répondre en co-traitance" in email_body) + self.assertNotEqual( + TenderSiae.objects.get(tender=self.tender, siae=self.siae).detail_cocontracting_click_date, None + ) + def test_user_can_notify_cocontracting_wish_with_authenticated_user(self): + url = reverse("tenders:detail-cocontracting-click", kwargs={"slug": self.tender.slug}) + self.assertEqual( + TenderSiae.objects.get(tender=self.tender, siae=self.siae).detail_cocontracting_click_date, None + ) self.client.force_login(self.siae_user) with mock.patch("lemarche.www.tenders.tasks.send_mail_async") as mock_send_mail_async: response = self.client.post(url, data={}) - self.assertContains(response, "Nous avons bien pris en compte votre demande de mise en relation") + self.assertContains(response, "Votre intérêt a bien été signalé au client.") mock_send_mail_async.assert_called_once() email_body = mock_send_mail_async.call_args[1]["email_body"] self.assertTrue(f"La structure {self.siae.name } souhaite répondre en co-traitance" in email_body) + self.assertNotEqual( + TenderSiae.objects.get(tender=self.tender, siae=self.siae).detail_cocontracting_click_date, None + ) user_without_siae = UserFactory(kind=User.KIND_SIAE) self.client.force_login(user_without_siae) with mock.patch("lemarche.www.tenders.tasks.send_mail_async") as mock_send_mail_async: response = self.client.post(url, data={}) - self.assertContains(response, "nous n'avons pas pu prendre en compte votre demande de mise en relation") + self.assertContains( + response, "nous n'avons pas pu prendre en compte votre souhait de répondre en co-traitance" + ) mock_send_mail_async.assert_not_called()