"""Test integration of an app with SQS.""" from unittest import mock import boto3 from botocore.exceptions import ProfileNotFound from video.connectors import sqs def test_get_connection(mocker): """Test if get_connection() returns a valid connection object.""" # test function call mocker.patch.object( boto3, 'resource', autospec=True, return_value='sdfds') connection = sqs.get_sqs_resource() assert connection == 'sdfds' @mock.patch('boto3.resource') def test_get_connection_failure(boto3_mock): """Test if get_connection() returns a valid connection object.""" # mocking boto3_mock.side_effect = ProfileNotFound(profile='none') # test function call sqs_resource = sqs.get_sqs_resource() # checking assert sqs_resource is None @mock.patch('video.connectors.sqs.get_sqs_resource') def test_get_queue_failure(get_sqs_resources_mock): """Test failure if get_queue() returns None.""" # data preparation test_queue_url = 'test_queue_url' # mocking get_sqs_resources_mock.return_value = None # test function call queue = sqs.get_queue(test_queue_url) # checking assert queue is None