Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Sep 28, 2023
1 parent 73a28bf commit 53a8b93
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 5 deletions.
20 changes: 20 additions & 0 deletions lemarche/templates/tenders/_detail_admin_extra_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ <h2 class="h3">Informations Admin</h2>
<div class="row">
<div class="col-12">
<ul class="list-unstyled mb-0">
<li class="mb-2">
Publié le {{ tender.published_at|date }}
</li>
<li class="mb-2">
{% if tender.is_validated %}
Validé le {{ tender.validated_at|date }}
{% else %}
Statut : {{ tender.get_status_display }}
{% endif %}
</li>
<li class="mb-2">
<i class="ri-focus-2-line"></i>
{{ tender.siae_email_send_date_count }} prestataire{{ tender.siae_email_send_date_count|pluralize }} ciblé{{ tender.siae_email_send_date_count|pluralize }}
Expand All @@ -15,6 +25,16 @@ <h2 class="h3">Informations Admin</h2>
<i class="ri-thumb-up-line"></i>
{{ tender.siae_detail_contact_click_date_count }} prestataire{{ tender.siae_detail_contact_click_date_count|pluralize }} intéressé{{ tender.siae_detail_contact_click_date_count|pluralize }}
</li>
{% if not tender.deadline_date_outdated %}
<li class="mb-2">
Transactionné :
{% if tender.siae_transactioned == None %}
Inconnu
{% else %}
{{ tender.siae_transactioned.value|yesno:"Oui,Non" }}
{% endif %}
</li>
{% endif %}
<li>
<a href="{% url 'admin:tenders_tender_change' tender.id %}" target="_blank" id="tender-detail-admin-btn" class="btn btn-sm btn-outline-primary btn-ico">
<span>
Expand Down
34 changes: 29 additions & 5 deletions lemarche/www/siaes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,11 +1088,35 @@ def test_should_bring_the_siae_closer_to_the_city_to_the_top(self):
class SiaeDetailTest(TestCase):
@classmethod
def setUpTestData(cls):
cls.user = UserFactory()
cls.user_buyer = UserFactory(kind="BUYER")
cls.user_partner = UserFactory(kind="PARTNER")
cls.user_siae = UserFactory(kind="SIAE")
cls.user_admin = UserFactory(kind="ADMIN")
cls.siae = SiaeFactory(name="ABC Insertion")
cls.siae.users.add(cls.user_siae)

def test_should_display_contact_fields_to_authenticated_users(self):
siae = SiaeFactory(name="Ma boite", contact_email="[email protected]")
self.client.force_login(self.user)
url = reverse("siae:detail", args=[siae.slug])
def test_should_display_contact_cta(self):
url = reverse("siae:detail", args=[self.siae.slug])
# anonymous
response = self.client.get(url)
self.assertContains(response, "Contacter la structure")
# authenticated
for user in [self.user_buyer, self.user_partner, self.user_siae, self.user_admin]:
self.client.force_login(user)
response = self.client.get(url)
self.assertContains(response, "Contacter la structure")

def test_admin_has_extra_info(self):
url = reverse("siae:detail", args=[self.siae.slug])
# anonymous
response = self.client.get(url)
self.assertNotContains(response, "Informations Admin")
# other users
for user in [self.user_buyer, self.user_partner, self.user_siae]:
self.client.force_login(user)
response = self.client.get(url)
self.assertNotContains(response, "Informations Admin")
# admin
self.client.force_login(self.user_admin)
response = self.client.get(url)
self.assertContains(response, "Informations Admin")
15 changes: 15 additions & 0 deletions lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,21 @@ def test_tender_author_has_additional_stats(self):
self.assertNotContains(response, "1 prestataire ciblé")
self.assertNotContains(response, "1 prestataire intéressé")

def test_admin_has_extra_info(self):
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
# anonymous
response = self.client.get(url)
self.assertNotContains(response, "Informations Admin")
# other users
for user in [self.user_buyer_1, self.user_partner, self.siae_user_1]:
self.client.force_login(user)
response = self.client.get(url)
self.assertNotContains(response, "Informations Admin")
# admin
self.client.force_login(self.user_admin)
response = self.client.get(url)
self.assertContains(response, "Informations Admin")

def test_update_tendersiae_stats_on_tender_view(self):
self.tender_1.siaes.add(self.siae_2)
self.assertEqual(self.tender_1.tendersiae_set.count(), 1 + 1)
Expand Down

0 comments on commit 53a8b93

Please sign in to comment.