"""Tests for S3 connector.""" from unittest.mock import patch import pytest import config from src.connectors import s3 @pytest.mark.parametrize( 'input_path, expected', [ ('1_1_object.pdf', f's3://{config.S3_BUCKET}/1_1_object.pdf'), ( '/many/many/directories/1_2_object.pdf', f's3://{config.S3_BUCKET}/many/many/directories/1_2_object.pdf', ), ( 'many/many/directories/1_3_object.pdf', f's3://{config.S3_BUCKET}/many/many/directories/1_3_object.pdf', ), ], ) def test_full_path(input_path, expected): """Test for getting the full path to an S3 object.""" result = s3.full_path(input_path) assert result == expected @patch('src.connectors.s3.boto3') @pytest.mark.parametrize( 'file_path, object_name', [ ('/test/one.pdf', 'one.pdf'), ('/test/of/a/longer/path/two.pdf', 'two.pdf'), ('/tmp/three.pdf', '123/533/three.pdf'), ], ) def test_upload_file(boto3_mock, file_path, object_name): """Test uploading a file to S3.""" s3.upload_file(file_path, object_name) boto3_mock.client('s3').upload_file.assert_called_once_with( file_path, config.S3_BUCKET, object_name )