From 8a9c4ce6949831163c10a7f40f0d1d64e0a66bd9 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Wed, 11 Oct 2023 12:02:24 +0200 Subject: [PATCH] Add tests on amount visibility --- lemarche/www/dashboard_networks/tests.py | 6 +++++- lemarche/www/tenders/tests.py | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lemarche/www/dashboard_networks/tests.py b/lemarche/www/dashboard_networks/tests.py index c8cd48297..b54d1b134 100644 --- a/lemarche/www/dashboard_networks/tests.py +++ b/lemarche/www/dashboard_networks/tests.py @@ -27,12 +27,14 @@ def setUpTestData(cls): cls.network_2 = NetworkFactory(name="Liste 2") cls.user_network_1 = UserFactory(kind=User.KIND_PARTNER, partner_network=cls.network_1) cls.user_network_2 = UserFactory(kind=User.KIND_PARTNER, partner_network=cls.network_2) - cls.user_buyer = UserFactory(kind=User.KIND_BUYER) + cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer") cls.user_without_network = UserFactory(kind=User.KIND_PARTNER) cls.siae_1 = SiaeFactory(networks=[cls.network_1]) cls.siae_2 = SiaeFactory() cls.tender_1 = TenderFactory( author=cls.user_buyer, + amount=tender_constants.AMOUNT_RANGE_100_150, + accept_share_amount=False, status=tender_constants.STATUS_VALIDATED, validated_at=timezone.now(), deadline_date=timezone.now() - timedelta(days=5), @@ -94,6 +96,8 @@ def test_tender_list_in_network_tender_list(self): response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertContains(response, self.tender_1.title) + self.assertContains(response, "Entreprise Buyer") + self.assertNotContains(response, "K€") # !accept_share_amount self.assertContains(response, "1 adhérent notifié") self.assertNotContains(response, self.tender_2.title) diff --git a/lemarche/www/tenders/tests.py b/lemarche/www/tenders/tests.py index 020dd3f62..aeab23de2 100644 --- a/lemarche/www/tenders/tests.py +++ b/lemarche/www/tenders/tests.py @@ -28,7 +28,7 @@ class TenderCreateViewTest(TestCase): @classmethod def setUpTestData(cls): cls.user_siae = UserFactory(kind=User.KIND_SIAE) - cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Test") + cls.user_buyer = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer") cls.sectors = [SectorFactory().slug for _ in range(3)] cls.location_slug = PerimeterFactory().slug @@ -343,7 +343,7 @@ def setUpTestData(cls): cls.siae_1 = SiaeFactory() cls.siae_2 = SiaeFactory(post_code=perimeter.post_codes[0]) cls.siae_user_2 = UserFactory(kind=User.KIND_SIAE, siaes=[cls.siae_1]) - cls.user_buyer_1 = UserFactory(kind=User.KIND_BUYER) + cls.user_buyer_1 = UserFactory(kind=User.KIND_BUYER, company_name="Entreprise Buyer") cls.user_buyer_2 = UserFactory(kind=User.KIND_BUYER) cls.user_partner = UserFactory(kind=User.KIND_PARTNER) cls.tender = TenderFactory(author=cls.user_buyer_1, validated_at=timezone.now(), perimeters=[perimeter]) @@ -352,6 +352,8 @@ def setUpTestData(cls): ) cls.tender_3 = TenderFactory( author=cls.user_buyer_1, + amount=tender_constants.AMOUNT_RANGE_100_150, + accept_share_amount=False, validated_at=timezone.now(), deadline_date=timezone.now() - timedelta(days=5), perimeters=[perimeter], @@ -386,6 +388,9 @@ def test_siae_user_should_see_matching_tenders(self): response = self.client.get(url) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.context["tenders"]), 1) + self.assertContains(response, self.tender_3.title) + self.assertContains(response, "Entreprise Buyer") + self.assertNotContains(response, "K€") # !accept_share_amount self.assertNotContains(response, "2 prestataires ciblés") # tender_3, but only visible to author self.assertNotContains(response, "1 prestataire intéressé") # tender_3, but only visible to author