Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Sep 11, 2023
1 parent a4ec5ff commit 9b47f69
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
3 changes: 1 addition & 2 deletions lemarche/templates/tenders/_detail_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ <h1>
</div>
</div>
<div class="row text-bold">
<div class="col"
title="Secteurs d'activité : {{ tender.sectors_full_list_string|safe }}">
<div class="col" title="Secteurs d'activité : {{ tender.sectors_full_list_string|safe }}">
<i class="ri-award-line"></i>
{{ tender.sectors_list_string|safe }}
</div>
Expand Down
25 changes: 23 additions & 2 deletions lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,12 +441,24 @@ def setUpTestData(cls):
cls.user_buyer_2 = UserFactory(kind=User.KIND_BUYER)
cls.user_partner = UserFactory(kind=User.KIND_PARTNER)
cls.user_admin = UserFactory(kind=User.KIND_ADMIN)
sector_1 = SectorFactory(name="Bricolage")
grenoble_perimeter = PerimeterFactory(
name="Grenoble",
kind=Perimeter.KIND_CITY,
insee_code="38185",
department_code="38",
region_code="84",
post_codes=["38000", "38100", "38700"],
# coords=Point(5.7301, 45.1825),
)
cls.tender_1 = TenderFactory(
kind=tender_constants.KIND_TENDER,
author=cls.user_buyer_1,
amount=tender_constants.AMOUNT_RANGE_100_150,
accept_share_amount=True,
response_kind=[Tender.RESPONSE_KIND_EMAIL],
sectors=[sector_1],
location=grenoble_perimeter,
)
cls.tendersiae_1_1 = TenderSiae.objects.create(
tender=cls.tender_1,
Expand All @@ -458,6 +470,7 @@ def setUpTestData(cls):
detail_contact_click_date=timezone.now(),
)
TenderQuestionFactory(tender=cls.tender_1)
cls.tender_2 = TenderFactory(author=cls.user_buyer_1, contact_company_name="Another company")

def test_anyone_can_view_validated_tenders(self):
# anonymous
Expand Down Expand Up @@ -501,8 +514,16 @@ def test_tender_basic_fields_display(self):
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
# tender.author.company_name
self.assertContains(response, "Entreprise Buyer")
# sector
self.assertContains(response, "Bricolage")
# localisation
self.assertContains(response, "Grenoble")
# company_name
self.assertContains(response, "Entreprise Buyer") # tender.author.company_name
url = reverse("tenders:detail", kwargs={"slug": self.tender_2.slug})
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "Another company") # tender.contact_company_name

def test_tender_questions_display(self):
# tender with questions: section should be visible
Expand Down

0 comments on commit 9b47f69

Please sign in to comment.