Refactor code

- Created TaskNames for DVLA_FILES rather than have DVLA_FILES in QueueNames
- Removed PROCESS_FTP from all_queues() as this was causing problems in picking up letter job tasks
- Created test to ensure that we don't arbitrarily add queue names to all_queues
This commit is contained in:
Ken Tsang
2017-08-22 15:49:56 +01:00
parent 41fce57932
commit 4fb5e68ce7
5 changed files with 28 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ from app.celery.scheduled_tasks import (
timeout_notifications,
populate_monthly_billing)
from app.clients.performance_platform.performance_platform_client import PerformancePlatformClient
from app.config import QueueNames
from app.config import QueueNames, TaskNames
from app.dao.jobs_dao import dao_get_job_by_id
from app.dao.notifications_dao import dao_get_scheduled_notifications
from app.dao.provider_details_dao import (
@@ -695,6 +695,6 @@ def test_run_letter_jobs(client, mocker, sample_letter_template):
run_letter_jobs()
mock_celery.assert_called_once_with(name=QueueNames.DVLA_FILES,
mock_celery.assert_called_once_with(name=TaskNames.DVLA_FILES,
args=([job.id for job in jobs]),
queue=QueueNames.PROCESS_FTP)

View File

@@ -5,6 +5,7 @@ from unittest import mock
import pytest
from app import config
from app.config import QueueNames
def cf_conf():
@@ -57,3 +58,20 @@ def test_load_config_if_cloudfoundry_not_available(monkeypatch, reload_config):
def test_cloudfoundry_config_has_different_defaults():
# these should always be set on Sandbox
assert config.Sandbox.REDIS_ENABLED is False
def test_queue_names_all_queues_correct():
# Need to ensure that all_queues() only returns queue names used in API
queues = QueueNames.all_queues()
assert len(queues) == 10
assert set([QueueNames.PRIORITY,
QueueNames.PERIODIC,
QueueNames.DATABASE,
QueueNames.SEND_SMS,
QueueNames.SEND_EMAIL,
QueueNames.RESEARCH_MODE,
QueueNames.STATISTICS,
QueueNames.JOBS,
QueueNames.RETRY,
QueueNames.NOTIFY
]) == set(queues)