diff --git a/requirements-app.txt b/requirements-app.txt index f2aacc001..aa18a66f9 100644 --- a/requirements-app.txt +++ b/requirements-app.txt @@ -26,5 +26,4 @@ notifications-python-client==5.5.1 # PaaS awscli-cwlogs>=1.4,<1.5 - -git+https://github.com/alphagov/notifications-utils.git@36.12.0#egg=notifications-utils==36.12.0 +git+https://github.com/alphagov/notifications-utils.git@36.12.2#egg=notifications-utils==36.12.2 diff --git a/requirements.txt b/requirements.txt index 2b3051305..a5a59a6cb 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,20 +29,20 @@ notifications-python-client==5.5.1 awscli-cwlogs>=1.4,<1.5 -git+https://github.com/alphagov/notifications-utils.git@36.12.0#egg=notifications-utils==36.12.0 +git+https://github.com/alphagov/notifications-utils.git@36.12.2#egg=notifications-utils==36.12.2 ## The following requirements were added by pip freeze: alembic==1.4.2 amqp==1.4.9 anyjson==0.3.3 attrs==19.3.0 -awscli==1.18.37 +awscli==1.18.39 bcrypt==3.1.7 billiard==3.3.0.23 bleach==3.1.4 boto==2.49.0 boto3==1.10.38 -botocore==1.15.37 +botocore==1.15.39 certifi==2020.4.5.1 chardet==3.0.4 click==7.1.1 @@ -54,7 +54,7 @@ future==0.18.2 greenlet==0.4.15 idna==2.9 importlib-metadata==1.6.0 -Jinja2==2.11.1 +Jinja2==2.11.2 jmespath==0.9.5 kombu==3.0.37 Mako==1.1.2 diff --git a/tests/app/dao/test_jobs_dao.py b/tests/app/dao/test_jobs_dao.py index d8905ebc3..230e279d6 100644 --- a/tests/app/dao/test_jobs_dao.py +++ b/tests/app/dao/test_jobs_dao.py @@ -336,7 +336,7 @@ def assert_job_stat(job, result, sent, delivered, failed): @freeze_time('2019-06-13 13:00') def test_dao_cancel_letter_job_cancels_job_and_returns_number_of_cancelled_notifications( - sample_letter_template, admin_request + sample_letter_template ): job = create_job(template=sample_letter_template, notification_count=1, job_status='finished') notification = create_notification(template=job.template, job=job, status='created') @@ -347,7 +347,7 @@ def test_dao_cancel_letter_job_cancels_job_and_returns_number_of_cancelled_notif @freeze_time('2019-06-13 13:00') -def test_can_letter_job_be_cancelled_returns_true_if_job_can_be_cancelled(sample_letter_template, admin_request): +def test_can_letter_job_be_cancelled_returns_true_if_job_can_be_cancelled(sample_letter_template): job = create_job(template=sample_letter_template, notification_count=1, job_status='finished') create_notification(template=job.template, job=job, status='created') result, errors = can_letter_job_be_cancelled(job) @@ -357,7 +357,7 @@ def test_can_letter_job_be_cancelled_returns_true_if_job_can_be_cancelled(sample @freeze_time('2019-06-13 13:00') def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_notification_status_sending( - sample_letter_template, admin_request + sample_letter_template ): job = create_job(template=sample_letter_template, notification_count=2, job_status='finished') create_notification(template=job.template, job=job, status='sending') @@ -368,7 +368,7 @@ def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_notifica def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_letters_already_sent_to_dvla( - sample_letter_template, admin_request + sample_letter_template ): with freeze_time('2019-06-13 13:00'): job = create_job(template=sample_letter_template, notification_count=1, job_status='finished') @@ -384,7 +384,7 @@ def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_letters_ @freeze_time('2019-06-13 13:00') def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_not_a_letter_job( - sample_template, admin_request + sample_template ): job = create_job(template=sample_template, notification_count=1, job_status='finished') create_notification(template=job.template, job=job, status='created') @@ -395,7 +395,7 @@ def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_not_a_le @freeze_time('2019-06-13 13:00') def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_job_not_finished( - sample_letter_template, admin_request + sample_letter_template ): job = create_job(template=sample_letter_template, notification_count=1, job_status="in progress") create_notification(template=job.template, job=job, status='created') @@ -406,7 +406,7 @@ def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_job_not_ @freeze_time('2019-06-13 13:00') def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_notifications_not_in_db_yet( - sample_letter_template, admin_request + sample_letter_template ): job = create_job(template=sample_letter_template, notification_count=2, job_status='finished') create_notification(template=job.template, job=job, status='created') @@ -415,6 +415,17 @@ def test_can_letter_job_be_cancelled_returns_false_and_error_message_if_notifica assert errors == "We are still processing these letters, please try again in a minute." +def test_can_letter_job_be_cancelled_respects_bst(sample_letter_template): + job = create_job(template=sample_letter_template, created_at=datetime(2020, 4, 9, 23, 30), job_status='finished') + create_notification(template=job.template, job=job, status='created', created_at=datetime(2020, 4, 9, 23, 32)) + + with freeze_time('2020-04-10 10:00'): + result, errors = can_letter_job_be_cancelled(job) + + assert not errors + assert result + + def test_find_jobs_with_missing_rows(sample_email_template): healthy_job = create_job(template=sample_email_template, notification_count=3, diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 637683453..403d5d6fd 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -3350,12 +3350,18 @@ def test_cancel_notification_for_service_raises_error_if_its_too_late_to_cancel( assert response['result'] == 'error' +@pytest.mark.parametrize('created_at', [ + datetime(2018, 7, 6, 22, 30), # yesterday evening + datetime(2018, 7, 6, 23, 30), # this morning early hours (in bst) + datetime(2018, 7, 7, 10, 0), # this morning normal hours +]) @freeze_time('2018-7-7 16:00:00') def test_cancel_notification_for_service_updates_letter_if_still_time_to_cancel( admin_request, sample_letter_notification, + created_at, ): - sample_letter_notification.created_at = datetime(2018, 7, 7, 10, 0) + sample_letter_notification.created_at = created_at response = admin_request.post( 'service.cancel_notification_for_service',