From 89d766c8a81a2d938140318a9060ccf174546edd Mon Sep 17 00:00:00 2001 From: Facundo Batista Date: Fri, 26 Jan 2024 20:16:55 -0300 Subject: [PATCH] Patch the constant so it's testeable. --- joboffers/tests/test_notify-pending_moderation_offers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/joboffers/tests/test_notify-pending_moderation_offers.py b/joboffers/tests/test_notify-pending_moderation_offers.py index d52035e..192addd 100644 --- a/joboffers/tests/test_notify-pending_moderation_offers.py +++ b/joboffers/tests/test_notify-pending_moderation_offers.py @@ -1,10 +1,11 @@ import pytest from datetime import timedelta +from unittest.mock import patch from django.utils import timezone -from joboffers.constants import PENDING_MODERATION_OFFER_DAYS, TELEGRAM_PENDING_MODERATION_MESSAGE +from joboffers.constants import TELEGRAM_PENDING_MODERATION_MESSAGE from joboffers.models import JobOffer, OfferState from joboffers.management.commands.notify_pending_moderation_offers import ( notify_pending_moderation_offers @@ -14,6 +15,9 @@ @pytest.mark.django_db +@patch( + "joboffers.management.commands.notify_pending_moderation_offers.PENDING_MODERATION_OFFER_DAYS", + 2) def test_remind_offers_in_moderation(telegram_dummy): """Expiration of old joboffers command.""" today = timezone.now() @@ -34,5 +38,5 @@ def test_remind_offers_in_moderation(telegram_dummy): assert len(telegram_history) == 1 assert sent_message.endswith(TELEGRAM_PENDING_MODERATION_MESSAGE.format( offer_url=offer2.get_full_url(), - moderation_reminder_days=PENDING_MODERATION_OFFER_DAYS + moderation_reminder_days=2 ))