Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Dec 1, 2023
1 parent a4bc772 commit a65f146
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lemarche/templates/tenders/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1>{{ page_title }}</h1>
{% url 'tenders:list' as TENDERS_LIST_URL %}
{% url 'tenders:list' status=tender_constants.STATUS_DRAFT as TENDERS_DRAFT_LIST_URL %}
{% url 'tenders:list' status=tender_constants.STATUS_PUBLISHED as TENDERS_PUBLISHED_LIST_URL %}
{% url 'tenders:list' status=tender_constants.STATUS_VALIDATED as TENDERS_VALIDATED_LIST_URL %}
{% url 'tenders:list' status=tender_constants.STATUS_SENT as TENDERS_SENT_LIST_URL %}

<li class="nav-item">
<a role="button" hx-push-url="true" hx-get="{{ TENDERS_LIST_URL }}"
Expand All @@ -71,8 +71,8 @@ <h1>{{ page_title }}</h1>
</a>
</li>
<li class="nav-item">
<a role="button" hx-push-url="true" hx-get="{{ TENDERS_VALIDATED_LIST_URL }}"
class="nav-link{% if request.get_full_path == TENDERS_VALIDATED_LIST_URL %} active{% endif %}"
<a role="button" hx-push-url="true" hx-get="{{ TENDERS_SENT_LIST_URL }}"
class="nav-link{% if request.get_full_path == TENDERS_SENT_LIST_URL %} active{% endif %}"
hx-target="#tendersList" hx-swap="outerHTML">
Envoyé
</a>
Expand All @@ -93,7 +93,7 @@ <h1>{{ page_title }}</h1>
{% if request.get_full_path == TENDERS_PUBLISHED_LIST_URL %}
Vous n'avez aucun besoin en cours de validation pour le moment.
{% endif %}
{% if request.get_full_path == TENDERS_VALIDATED_LIST_URL %}
{% if request.get_full_path == TENDERS_SENT_LIST_URL %}
Vous n'avez aucun besoin d'envoyé pour le moment.
<br />
Contacter notre équipe en cas de problème avec un de vos dépôts de besoins en cours de validation.
Expand Down
3 changes: 2 additions & 1 deletion lemarche/tenders/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Meta:
start_working_date = date.today() + timedelta(days=random.randint(12, 90))
author = factory.SubFactory(UserFactory)
validated_at = timezone.now()
sent_at = timezone.now()
external_link = factory.Sequence("https://{0}example.com".format)
# Contact fields
contact_first_name = factory.Sequence("first_name{0}".format)
Expand All @@ -43,7 +44,7 @@ class Meta:
contact_phone = factory.fuzzy.FuzzyText(length=10, chars=string.digits)
# amount = tender_constants.AMOUNT_RANGE_100_150
# marche_benefits = factory.fuzzy.FuzzyChoice([key for (key, _) in constants.MARCHE_BENEFIT_CHOICES])
status = tender_constants.STATUS_VALIDATED
status = tender_constants.STATUS_SENT

@factory.post_generation
def perimeters(self, create, extracted, **kwargs):
Expand Down
2 changes: 2 additions & 0 deletions lemarche/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ def test_status(self):
tender_pending_validation = TenderFactory(status=tender_constants.STATUS_PUBLISHED)
tender_validated_half = TenderFactory(status=tender_constants.STATUS_VALIDATED)
tender_validated_full = TenderFactory(status=tender_constants.STATUS_VALIDATED, validated_at=timezone.now())
tender_sent = TenderFactory(status=tender_constants.STATUS_SENT, sent_at=timezone.now())
self.assertTrue(tender_draft.is_draft, True)
self.assertTrue(tender_pending_validation.is_pending_validation, True)
self.assertTrue(tender_validated_half.is_validated, False)
self.assertTrue(tender_validated_full.is_validated, True)
self.assertTrue(tender_sent.is_sent, True)

def test_amount_display(self):
tender_with_amount = TenderFactory(amount=tender_constants.AMOUNT_RANGE_0_1, accept_share_amount=True)
Expand Down
2 changes: 1 addition & 1 deletion lemarche/www/dashboard_networks/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def setUpTestData(cls):
author=cls.user_buyer,
amount=tender_constants.AMOUNT_RANGE_100_150,
accept_share_amount=False,
status=tender_constants.STATUS_VALIDATED,
status=tender_constants.STATUS_SENT,
validated_at=timezone.now(),
deadline_date=timezone.now() - timedelta(days=5),
)
Expand Down
14 changes: 11 additions & 3 deletions lemarche/www/tenders/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ def setUpTestData(cls):
response_kind=[tender_constants.RESPONSE_KIND_EMAIL],
sectors=[sector_1],
location=grenoble_perimeter,
status=tender_constants.STATUS_SENT,
sent_at=timezone.now(),
)
cls.tendersiae_1_1 = TenderSiae.objects.create(
tender=cls.tender_1,
Expand All @@ -528,7 +530,7 @@ def setUpTestData(cls):
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):
def test_anyone_can_view_sent_tenders(self):
# anonymous
url = reverse("tenders:detail", kwargs={"slug": self.tender_1.slug})
response = self.client.get(url)
Expand All @@ -541,12 +543,18 @@ def test_anyone_can_view_validated_tenders(self):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)

def test_only_author_or_admin_can_view_non_validated_tender(self):
def test_only_author_or_admin_can_view_non_sent_tender(self):
tender_draft = TenderFactory(author=self.user_buyer_1, status=tender_constants.STATUS_DRAFT)
tender_published = TenderFactory(
author=self.user_buyer_1, status=tender_constants.STATUS_PUBLISHED, published_at=timezone.now()
)
for tender in [tender_draft, tender_published]:
tender_validated_but_not_sent = TenderFactory(
author=self.user_buyer_1,
status=tender_constants.STATUS_VALIDATED,
published_at=timezone.now(),
validated_at=timezone.now(),
)
for tender in [tender_draft, tender_published, tender_validated_but_not_sent]:
# anonymous
url = reverse("tenders:detail", kwargs={"slug": tender.slug})
response = self.client.get(url)
Expand Down

0 comments on commit a65f146

Please sign in to comment.