From 33f99c2d0e11a1d5dce1ace08d0e4fa129b76e65 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Wed, 14 Feb 2024 15:34:54 +0100 Subject: [PATCH] add tests --- lemarche/api/tenders/tests.py | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lemarche/api/tenders/tests.py b/lemarche/api/tenders/tests.py index c7528322c..d7be81d93 100644 --- a/lemarche/api/tenders/tests.py +++ b/lemarche/api/tenders/tests.py @@ -161,6 +161,45 @@ def test_create_tender_with_different_contact_data(self): self.assertEqual(author.buyer_kind_detail, user_constants.BUYER_KIND_DETAIL_PUBLIC_ASSOCIATION) +def test_create_tender_with_include_country_area(self): + tender_data = TENDER_JSON.copy() + title = "Test tally include_country_area" + tender_data["title"] = title + tender_data["extra_data"] = {"source": "TALLY"} + response = self.client.post(self.url, data=tender_data, content_type="application/json") + self.assertEqual(response.status_code, 201) + tender = Tender.objects.get(title=title) + self.assertEqual(tender.include_country_area, False) + # when include country area is True + title = "Test tally include_country_area is True" + tender_data["title"] = title + tender_data["include_country_area"] = "true" + response = self.client.post(self.url, data=tender_data, content_type="application/json") + self.assertEqual(response.status_code, 201) + tender = Tender.objects.get(title=title) + self.assertEqual(tender.include_country_area, True) + + +def test_create_tender_with_distance_location(self): + tender_data = TENDER_JSON.copy() + title = "Test tally distance_location" + tender_data["title"] = title + tender_data["extra_data"] = {"source": "TALLY"} + response = self.client.post(self.url, data=tender_data, content_type="application/json") + self.assertEqual(response.status_code, 201) + tender = Tender.objects.get(title=title) + self.assertEqual(tender.distance_location, None) + # when distance_location is set + tender_data["distance_location"] = 60 + title = "Test tally distance_location is 60" + tender_data["title"] = title + tender_data["extra_data"] = {"source": "TALLY"} + response = self.client.post(self.url, data=tender_data, content_type="application/json") + self.assertEqual(response.status_code, 201) + tender = Tender.objects.get(title=title) + self.assertEqual(tender.distance_location, 60) + + class TenderCreateApiPartnerTest(TestCase): @classmethod def setUpTestData(cls):