From 39a37fcb864978f3a32e9db0f1f0bfc49e63a84b Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 14 Feb 2024 17:49:04 +0100 Subject: [PATCH] update tests --- lemarche/tenders/tests.py | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lemarche/tenders/tests.py b/lemarche/tenders/tests.py index 2b942b4b1..0ee1e8c31 100644 --- a/lemarche/tenders/tests.py +++ b/lemarche/tenders/tests.py @@ -663,15 +663,17 @@ def setUpTestData(cls): # coords=Point(5.7301, 45.1825), ) # partners - PartnerShareTenderFactory(perimeters=[]) - PartnerShareTenderFactory(perimeters=[cls.auvergne_rhone_alpes_perimeter]) - PartnerShareTenderFactory(perimeters=[cls.isere_perimeter]) - PartnerShareTenderFactory(perimeters=[cls.grenoble_perimeter]) - PartnerShareTenderFactory(perimeters=[], amount_in=tender_constants.AMOUNT_RANGE_0_1) - PartnerShareTenderFactory(perimeters=[], amount_in=tender_constants.AMOUNT_RANGE_10_15) - PartnerShareTenderFactory(perimeters=[], amount_in=tender_constants.AMOUNT_RANGE_100_150) + PartnerShareTenderFactory(perimeters=[], is_active=True) + PartnerShareTenderFactory(perimeters=[cls.auvergne_rhone_alpes_perimeter], is_active=True) + PartnerShareTenderFactory(perimeters=[cls.isere_perimeter], is_active=True) + PartnerShareTenderFactory(perimeters=[cls.grenoble_perimeter], is_active=True) + PartnerShareTenderFactory(perimeters=[], amount_in=tender_constants.AMOUNT_RANGE_0_1, is_active=True) + PartnerShareTenderFactory(perimeters=[], amount_in=tender_constants.AMOUNT_RANGE_10_15, is_active=True) + PartnerShareTenderFactory(perimeters=[], amount_in=tender_constants.AMOUNT_RANGE_100_150, is_active=True) PartnerShareTenderFactory( - perimeters=[cls.isere_perimeter, cls.rhone_perimeter], amount_in=tender_constants.AMOUNT_RANGE_10_15 + perimeters=[cls.isere_perimeter, cls.rhone_perimeter], + amount_in=tender_constants.AMOUNT_RANGE_10_15, + is_active=True, ) def test_tender_country_matching(self): @@ -724,6 +726,20 @@ def test_tender_perimeters_and_amount_matching(self): result = PartnerShareTender.objects.filter_by_tender(tender_3) self.assertEqual(len(result), 3 + 3) + def test_tender_partner_is_active(self): + # partners with perimeters=[] + tender = TenderFactory(is_country_area=True) + # by default is_active is False + partner = PartnerShareTenderFactory(perimeters=[]) + result = PartnerShareTender.objects.filter_by_tender(tender) + self.assertEqual(len(result), 4) + # update partner + partner.is_active = True + partner.save() + # we should have +1 partner + result_2 = PartnerShareTender.objects.filter_by_tender(tender) + self.assertEqual(len(result_2), 4 + 1) + class TenderSiaeModelQuerysetTest(TestCase): @classmethod