test_delete_message.py 685 B

12345678910111213141516171819202122
  1. import pytest
  2. from backend.lambdas.tasks.delete_message import handler
  3. from mock import MagicMock, patch
  4. pytestmark = [pytest.mark.unit, pytest.mark.task]
  5. @patch("backend.lambdas.tasks.delete_message.sqs")
  6. def test_deletes_for_receipt_handle(sqs_mock):
  7. message_mock = MagicMock()
  8. sqs_mock.Message.return_value = message_mock
  9. handler({"ReceiptHandle": "test"}, MagicMock())
  10. message_mock.delete.assert_called()
  11. @patch("backend.lambdas.tasks.delete_message.sqs")
  12. def test_it_skips_if_no_receipt_handle(sqs_mock):
  13. message_mock = MagicMock()
  14. sqs_mock.Message.return_value = message_mock
  15. handler({}, MagicMock())
  16. message_mock.delete.assert_not_called()