diff --git a/scripts/test_s3.py b/test_scripts/test_scripts_for_s3.py similarity index 97% rename from scripts/test_s3.py rename to test_scripts/test_scripts_for_s3.py index 3809cba24..4510c4e6d 100644 --- a/scripts/test_s3.py +++ b/test_scripts/test_scripts_for_s3.py @@ -42,7 +42,7 @@ def test_get_file_content(): print(content) -def test_letter_ack_file_strip_correctly(): +def test_letter_ack_file_parse_content_correctly(): # Test ack files are stripped correctly. In the acknowledgement file, there should be 2 zip files, # 'NOTIFY.20180111175007.ZIP','NOTIFY.20180111175008.ZIP'. zip_file_list = ['NOTIFY.20180111175007.ZIP', 'NOTIFY.20180111175008.ZIP', 'NOTIFY.20180111175009.ZIP'] diff --git a/tests/app/celery/test_scheduled_tasks.py b/tests/app/celery/test_scheduled_tasks.py index 5054afd82..2dfef2623 100644 --- a/tests/app/celery/test_scheduled_tasks.py +++ b/tests/app/celery/test_scheduled_tasks.py @@ -1039,9 +1039,9 @@ def mock_s3_get_list_match(bucket_name, subfolder='', suffix=''): def mock_s3_get_list_diff(bucket_name, subfolder='', suffix=''): - if subfolder == '2018-01-11': - return ['NOTIFY.20180111175007.ZIP', 'NOTIFY.20180111175008.ZIP', 'NOTIFY.20180111175009.ZIP'] + return ['NOTIFY.20180111175007.ZIP', 'NOTIFY.20180111175008.ZIP', 'NOTIFY.20180111175009.ZIP', + 'NOTIFY.20180111175010.ZIP'] print(suffix) if subfolder == 'root/dispatch': return ['root/dispatch/NOTIFY.20180111175733.ACK.txt'] @@ -1069,6 +1069,6 @@ def test_letter_not_raise_alert_if_ack_files_not_match_zip_list(mocker, notify_d with pytest.raises(expected_exception=NoAckFileReceived) as e: letter_raise_alert_if_no_ack_file_for_zip() - assert e.value.message == ['NOTIFY.20180111175009.ZIP'] + assert e.value.message == ['NOTIFY.20180111175009.ZIP', 'NOTIFY.20180111175010.ZIP'] assert mock_file_list.call_count == 2 assert mock_get_file.call_count == 1 diff --git a/tests/app/notifications/rest/test_callbacks.py b/tests/app/notifications/rest/test_callbacks.py index af51f7719..e81a91042 100644 --- a/tests/app/notifications/rest/test_callbacks.py +++ b/tests/app/notifications/rest/test_callbacks.py @@ -80,12 +80,14 @@ def test_dvla_callback_calls_update_letter_notifications_task(client, mocker): update_task.assert_called_with(['bar.rs.txt'], queue='notify-internal-tasks') -def test_dvla_callback_does_not_raise_error_parsing_json_for_plaintext_header(client, mocker): - mocker.patch('app.notifications.notifications_letter_callback.update_letter_notifications_statuses.apply_async') - data = _sample_sns_s3_callback() +def test_dvla_ack_calls_does_not_call_letter_notifications_task(client, mocker): + update_task = \ + mocker.patch('app.notifications.notifications_letter_callback.update_letter_notifications_statuses.apply_async') + data = _sample_sns_s3_dvla_ack() response = dvla_post(client, data) assert response.status_code == 200 + update_task.assert_not_called() def test_firetext_callback_should_not_need_auth(client, mocker): @@ -460,7 +462,7 @@ def test_firetext_callback_should_record_statsd(client, notify_db, notify_db_ses app.statsd_client.incr.assert_any_call("callback.firetext.delivered") -def _sample_sns_s3_callback(): +def _sample_sns_s3_dvla_ack(): return json.dumps({ "SigningCertURL": "foo.pem", "UnsubscribeURL": "bar", @@ -471,7 +473,7 @@ def _sample_sns_s3_callback(): "MessageId": "6adbfe0a-d610-509a-9c47-af894e90d32d", "Subject": "Amazon S3 Notification", "TopicArn": "sample-topic-arn", - "Message": '{"Records":[{"eventVersion":"2.0","eventSource":"aws:s3","awsRegion":"eu-west-1","eventTime":"2017-05-16T11:38:41.073Z","eventName":"ObjectCreated:Put","userIdentity":{"principalId":"some-p-id"},"requestParameters":{"sourceIPAddress":"8.8.8.8"},"responseElements":{"x-amz-request-id":"some-r-id","x-amz-id-2":"some-x-am-id"},"s3":{"s3SchemaVersion":"1.0","configurationId":"some-c-id","bucket":{"name":"some-bucket","ownerIdentity":{"principalId":"some-p-id"},"arn":"some-bucket-arn"},"object":{"key":"bar.txt","size":200,"eTag":"some-e-tag","versionId":"some-v-id","sequencer":"some-seq"}}}]}' # noqa + "Message": '{"Records":[{"eventVersion":"2.0","eventSource":"aws:s3","awsRegion":"eu-west-1","eventTime":"2017-05-16T11:38:41.073Z","eventName":"ObjectCreated:Put","userIdentity":{"principalId":"some-p-id"},"requestParameters":{"sourceIPAddress":"8.8.8.8"},"responseElements":{"x-amz-request-id":"some-r-id","x-amz-id-2":"some-x-am-id"},"s3":{"s3SchemaVersion":"1.0","configurationId":"some-c-id","bucket":{"name":"some-bucket","ownerIdentity":{"principalId":"some-p-id"},"arn":"some-bucket-arn"},"object":{"key":"bar.ack.txt","size":200,"eTag":"some-e-tag","versionId":"some-v-id","sequencer":"some-seq"}}}]}' # noqa })