Skip to content

Commit

Permalink
add celery task
Browse files Browse the repository at this point in the history
  • Loading branch information
depsiatwal committed Feb 12, 2024
1 parent 59e3e36 commit f3a78ab
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion api/cases/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def schedule_all_ecju_query_chaser_emails():
"""
Sends an ECJU 15 working days reminder
Runs as a background task daily at a given time.
Doesn't run on non-working days (bank-holidays & weekends)
Can accommodate reruns and can send reminders if any have been missed upto 20 days after ECJU Query created
"""
logger.info("Sending all ECJU query chaser emails started")

Expand Down
10 changes: 8 additions & 2 deletions api/cases/tests/test_case_ecju_queries.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from api.conf import settings
from django.conf import settings
from api.core.helpers import get_exporter_frontend_url
import pytest
import datetime
from unittest import mock
Expand Down Expand Up @@ -692,6 +693,10 @@ class ECJUQueriesChaserNotificationTests(DataTestClient):
def setUp(self):
super().setUp()
settings.GOV_NOTIFY_ENABLED = True
# Require a valid formatted key else NotificationsAPIClient will complain with missing service id key.
settings.GOV_NOTIFY_KEY = (
"faketestkey-aa1539a1-0ba4-4ac2-b6ff-ae557aed2169-aa1539a1-0ba4-4ac2-b6ff-ae557aed2169"
)
self.case = self.create_standard_application_case(self.organisation)
self.date_15_working_days_from_today = datetime.datetime(2024, 1, 16, 12, 00)

Expand Down Expand Up @@ -811,9 +816,10 @@ def test_schedule_all_ecju_query_chaser_emails_send_mail_params(self, mock_send_
schedule_all_ecju_query_chaser_emails.apply()

mock_send_email.assert_called_once()

expected_payload = ExporterECJUQueryChaser(
case_reference=self.case.reference_code,
exporter_frontend_ecju_queries_url=f"https://exporter.lite.service.localhost.uktrade.digital/applications/{self.case.pk}/ecju-queries/",
exporter_frontend_ecju_queries_url=get_exporter_frontend_url(f"/applications/{self.case.pk}/ecju-queries/"),
remaining_days=5,
)
mock_send_email.assert_called_with(
Expand Down
2 changes: 1 addition & 1 deletion api/conf/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
},
"send ecju query chaser emails 8pm, 4pm": {
"task": "api.cases.celery_tasks.schedule_all_ecju_query_chaser_emails",
"schedule": crontab(hour="8, 16", minute=0),
"schedule": crontab(hour="8, 12, 13, 15 ,16", minute=0),
},
}

0 comments on commit f3a78ab

Please sign in to comment.