Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jan 15, 2024
1 parent a08520b commit e56075b
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions lemarche/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ def setUpTestData(cls):
siae_with_tender_5 = SiaeFactory()
siae_with_tender_6 = SiaeFactory()
siae_with_tender_7 = SiaeFactory()
siae_with_tender_8 = SiaeFactory()
cls.siae_without_tender = SiaeFactory()
cls.tender_with_siae_1 = TenderFactory(
siaes=[cls.siae_with_tender_1, siae_with_tender_2], deadline_date=date_tomorrow
Expand Down Expand Up @@ -323,8 +324,17 @@ def setUpTestData(cls):
siae=siae_with_tender_7,
email_send_date=timezone.now(),
email_link_click_date=timezone.now(),
detail_display_date=timezone.now(),
detail_cocontracting_click_date=timezone.now(),
)
TenderSiae.objects.create(
tender=cls.tender_with_siae_1,
siae=siae_with_tender_8,
email_send_date=timezone.now(),
email_link_click_date=timezone.now(),
detail_display_date=timezone.now(),
detail_not_interested_click_date=timezone.now(),
)
cls.tender_with_siae_2 = TenderFactory()
TenderSiae.objects.create(
tender=cls.tender_with_siae_2,
Expand All @@ -347,14 +357,15 @@ def test_filter_with_siaes(self):
def test_with_siae_stats(self):
self.assertEqual(Tender.objects.count(), 2 + 1)
tender_with_siae_1 = Tender.objects.with_siae_stats().filter(id=self.tender_with_siae_1.id).first()
self.assertEqual(tender_with_siae_1.siaes.count(), 7)
self.assertEqual(tender_with_siae_1.siae_count_annotated, 7)
self.assertEqual(tender_with_siae_1.siae_email_send_count_annotated, 5)
self.assertEqual(tender_with_siae_1.siae_email_link_click_count_annotated, 4)
self.assertEqual(tender_with_siae_1.siae_detail_display_count_annotated, 2)
self.assertEqual(tender_with_siae_1.siae_email_link_click_or_detail_display_count_annotated, 2)
self.assertEqual(tender_with_siae_1.siaes.count(), 8)
self.assertEqual(tender_with_siae_1.siae_count_annotated, 8)
self.assertEqual(tender_with_siae_1.siae_email_send_count_annotated, 6)
self.assertEqual(tender_with_siae_1.siae_email_link_click_count_annotated, 5)
self.assertEqual(tender_with_siae_1.siae_detail_display_count_annotated, 4)
self.assertEqual(tender_with_siae_1.siae_email_link_click_or_detail_display_count_annotated, 5)
self.assertEqual(tender_with_siae_1.siae_detail_contact_click_count_annotated, 1)
self.assertEqual(tender_with_siae_1.siae_detail_cocontracting_click_count_annotated, 1)
self.assertEqual(tender_with_siae_1.siae_detail_not_interested_click_count_annotated, 1)
self.assertEqual(tender_with_siae_1.siae_detail_contact_click_since_last_seen_date_count_annotated, 1)
tender_with_siae_2 = Tender.objects.with_siae_stats().filter(id=self.tender_with_siae_2.id).first()
self.assertEqual(tender_with_siae_2.siaes.count(), 1)
Expand All @@ -376,7 +387,7 @@ def test_with_siae_stats(self):
self.assertEqual(tender_without_siae.siae_detail_contact_click_since_last_seen_date_count_annotated, 0)

def test_siae_with_tender_stats(self):
self.assertEqual(Siae.objects.count(), 7 + 1)
self.assertEqual(Siae.objects.count(), 8 + 1)
siae_with_tender_1 = Siae.objects.with_tender_stats().filter(id=self.siae_with_tender_1.id).first()
# self.assertEqual(siae_with_tender_1.tenders.count(), 2)
self.assertEqual(siae_with_tender_1.tender_count_annotated, 2)
Expand Down

0 comments on commit e56075b

Please sign in to comment.