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:
venusbb
2018-01-12 19:24:36 +00:00
parent a016b3f8d6
commit 96b3c6c2ed
3 changed files with 11 additions and 9 deletions

View File

@@ -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
})