Skip to content

Commit

Permalink
Add tests on amount visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Oct 11, 2023
1 parent f4e8dbc commit 8a9c4ce
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lemarche/www/dashboard_networks/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)

Expand Down
9 changes: 7 additions & 2 deletions lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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])
Expand All @@ -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],
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 8a9c4ce

Please sign in to comment.