Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
madjid-asa committed Feb 14, 2024
1 parent 3dfb0af commit 33f99c2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions lemarche/api/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 33f99c2

Please sign in to comment.