mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-06 00:59:41 -04:00
Add tests for checking not updating database when ack file is received.
Moved S3 test scripts Modified scheduled_task test
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user