diff --git a/fixtures/aws.py b/fixtures/aws.py index deb78fceee..a0967415ea 100644 --- a/fixtures/aws.py +++ b/fixtures/aws.py @@ -6,7 +6,7 @@ import boto3 import pytest -from moto import mock_s3 +from moto import mock_aws @pytest.fixture(autouse=True) @@ -18,7 +18,7 @@ def silence_s3_logging(): # noqa: PT004 @pytest.fixture def mock_s3_fixture(): # noqa: PT004 """Mock the S3 fixture for the duration of the test""" - with mock_s3(): + with mock_aws(): yield diff --git a/learning_resources/etl/ocw_test.py b/learning_resources/etl/ocw_test.py index 7ffba2cf4c..476cbcd503 100644 --- a/learning_resources/etl/ocw_test.py +++ b/learning_resources/etl/ocw_test.py @@ -6,7 +6,7 @@ import boto3 import pytest -from moto import mock_s3 +from moto import mock_aws from learning_resources.conftest import OCW_TEST_PREFIX, setup_s3_ocw from learning_resources.constants import ( @@ -37,7 +37,7 @@ pytestmark = pytest.mark.django_db -@mock_s3 +@mock_aws @pytest.mark.parametrize("base_ocw_url", ["http://test.edu/", "http://test.edu"]) def test_transform_content_files(settings, mocker, base_ocw_url): """ @@ -111,7 +111,7 @@ def test_transform_content_files(settings, mocker, base_ocw_url): } -@mock_s3 +@mock_aws def test_transform_content_files_exceptions(settings, mocker): """ Test transform_content_files @@ -130,7 +130,7 @@ def test_transform_content_files_exceptions(settings, mocker): assert mock_log.call_count == 5 -@mock_s3 +@mock_aws @pytest.mark.parametrize("overwrite", [True, False]) @pytest.mark.parametrize("modified_after_last_import", [True, False]) def test_transform_content_file_needs_text_update( @@ -174,7 +174,7 @@ def test_transform_content_file_needs_text_update( assert "content" not in content_data -@mock_s3 +@mock_aws @pytest.mark.parametrize( ( "legacy_uid", diff --git a/learning_resources/etl/pipelines_test.py b/learning_resources/etl/pipelines_test.py index cc6411c46d..3c8ea38a26 100644 --- a/learning_resources/etl/pipelines_test.py +++ b/learning_resources/etl/pipelines_test.py @@ -6,7 +6,7 @@ from unittest.mock import patch import pytest -from moto import mock_s3 +from moto import mock_aws from learning_resources.conftest import OCW_TEST_PREFIX, setup_s3_ocw from learning_resources.constants import OfferedBy, PlatformType @@ -222,7 +222,7 @@ def test_podcast_etl(): assert result == mock_load_podcasts.return_value -@mock_s3 +@mock_aws @pytest.mark.django_db @pytest.mark.parametrize("skip_content_files", [True, False]) def test_ocw_courses_etl(settings, mocker, skip_content_files): @@ -268,7 +268,7 @@ def test_ocw_courses_etl(settings, mocker, skip_content_files): assert mock_calc_score.call_count == (0 if skip_content_files else 1) -@mock_s3 +@mock_aws @pytest.mark.django_db def test_ocw_courses_etl_no_data(settings, mocker): """Test ocw_courses_etl when no S3 data is present""" @@ -285,7 +285,7 @@ def test_ocw_courses_etl_no_data(settings, mocker): mock_log.assert_called_once_with("No course data found for %s", s3_path) -@mock_s3 +@mock_aws @pytest.mark.django_db def test_ocw_courses_etl_exception(settings, mocker): """Test ocw_courses_etl when bad data raises an exception""" diff --git a/learning_resources/tasks_test.py b/learning_resources/tasks_test.py index 7739374ae4..065ce3af9a 100644 --- a/learning_resources/tasks_test.py +++ b/learning_resources/tasks_test.py @@ -8,7 +8,7 @@ import pytest from decorator import contextmanager from django.utils import timezone -from moto import mock_s3 +from moto import mock_aws from learning_resources import factories, models, tasks from learning_resources.conftest import OCW_TEST_PREFIX, setup_s3, setup_s3_ocw @@ -129,7 +129,7 @@ def test_get_xpro_data(mocker): mock_pipelines.xpro_courses_etl.assert_called_once_with() -@mock_s3 +@mock_aws def test_import_all_mit_edx_files(settings, mocker, mocked_celery, mock_blocklist): """import_all_mit_edx_files should start chunked tasks with correct bucket, platform""" setup_s3(settings) @@ -145,7 +145,7 @@ def test_import_all_mit_edx_files(settings, mocker, mocked_celery, mock_blocklis ) -@mock_s3 +@mock_aws def test_import_all_mitxonline_files(settings, mocker, mocked_celery, mock_blocklist): """import_all_mitxonline_files should be replaced with get_content_tasks""" setup_s3(settings) @@ -161,7 +161,7 @@ def test_import_all_mitxonline_files(settings, mocker, mocked_celery, mock_block ) -@mock_s3 +@mock_aws def test_import_all_xpro_files(settings, mocker, mocked_celery, mock_blocklist): """import_all_xpro_files should start chunked tasks with correct bucket, platform""" setup_s3(settings) @@ -173,7 +173,7 @@ def test_import_all_xpro_files(settings, mocker, mocked_celery, mock_blocklist): get_content_tasks_mock.assert_called_once_with(PlatformType.xpro.name, chunk_size=3) -@mock_s3 +@mock_aws def test_import_all_oll_files(settings, mocker, mocked_celery, mock_blocklist): """import_all_oll_files should start chunked tasks with correct bucket, platform""" setup_s3(settings) @@ -190,7 +190,7 @@ def test_import_all_oll_files(settings, mocker, mocked_celery, mock_blocklist): ) -@mock_s3 +@mock_aws def test_get_content_tasks(settings, mocker, mocked_celery, mock_xpro_learning_bucket): """Test that get_content_tasks calls get_content_files with the correct args""" mock_get_content_files = mocker.patch( @@ -260,7 +260,7 @@ def test_get_podcast_data(mocker): mock_pipelines.podcast_etl.assert_called_once() -@mock_s3 +@mock_aws @pytest.mark.parametrize( ("force_overwrite", "skip_content_files"), [(True, False), (False, True)] ) @@ -313,7 +313,7 @@ def test_get_ocw_data_no_settings(settings, mocker): mock_log.assert_called_once_with("Required settings missing for get_ocw_data") -@mock_s3 +@mock_aws @pytest.mark.parametrize("timestamp", [None, "2020-12-15T00:00:00Z"]) @pytest.mark.parametrize("overwrite", [True, False]) def test_get_ocw_courses(settings, mocker, mocked_celery, timestamp, overwrite): diff --git a/poetry.lock b/poetry.lock index 20984a0a8d..7012092c41 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2503,46 +2503,48 @@ files = [ [[package]] name = "moto" -version = "4.2.14" +version = "5.0.18" description = "" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "moto-4.2.14-py2.py3-none-any.whl", hash = "sha256:6d242dbbabe925bb385ddb6958449e5c827670b13b8e153ed63f91dbdb50372c"}, - {file = "moto-4.2.14.tar.gz", hash = "sha256:8f9263ca70b646f091edcc93e97cda864a542e6d16ed04066b1370ed217bd190"}, + {file = "moto-5.0.18-py2.py3-none-any.whl", hash = "sha256:8e25401f7d7910e19a732b417e0d503ef86cf4de9114a273dd62679a42f3be1c"}, + {file = "moto-5.0.18.tar.gz", hash = "sha256:8a7ad2f53a2e6cc9db2ff65c0e0d4b5d7e78bc00b825c9e1ff6cc394371e76e9"}, ] [package.dependencies] boto3 = ">=1.9.201" -botocore = ">=1.12.201" +botocore = ">=1.14.0" cryptography = ">=3.3.1" Jinja2 = ">=2.10.1" python-dateutil = ">=2.1,<3.0.0" requests = ">=2.5" -responses = ">=0.13.0" +responses = ">=0.15.0" werkzeug = ">=0.5,<2.2.0 || >2.2.0,<2.2.1 || >2.2.1" xmltodict = "*" [package.extras] -all = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.0)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"] -apigateway = ["PyYAML (>=5.1)", "ecdsa (!=0.15)", "openapi-spec-validator (>=0.5.0)", "python-jose[cryptography] (>=3.1.0,<4.0.0)"] -apigatewayv2 = ["PyYAML (>=5.1)"] +all = ["PyYAML (>=5.1)", "antlr4-python3-runtime", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "graphql-core", "joserfc (>=0.9.0)", "jsondiff (>=1.1.2)", "jsonpath-ng", "jsonschema", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.6)", "pyparsing (>=3.0.7)", "setuptools"] +apigateway = ["PyYAML (>=5.1)", "joserfc (>=0.9.0)", "openapi-spec-validator (>=0.5.0)"] +apigatewayv2 = ["PyYAML (>=5.1)", "openapi-spec-validator (>=0.5.0)"] appsync = ["graphql-core"] awslambda = ["docker (>=3.0.0)"] batch = ["docker (>=3.0.0)"] -cloudformation = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.0)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"] -cognitoidp = ["ecdsa (!=0.15)", "python-jose[cryptography] (>=3.1.0,<4.0.0)"] -dynamodb = ["docker (>=3.0.0)", "py-partiql-parser (==0.5.0)"] -dynamodbstreams = ["docker (>=3.0.0)", "py-partiql-parser (==0.5.0)"] -ec2 = ["sshpubkeys (>=3.1.0)"] +cloudformation = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "graphql-core", "joserfc (>=0.9.0)", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.6)", "pyparsing (>=3.0.7)", "setuptools"] +cognitoidp = ["joserfc (>=0.9.0)"] +dynamodb = ["docker (>=3.0.0)", "py-partiql-parser (==0.5.6)"] +dynamodbstreams = ["docker (>=3.0.0)", "py-partiql-parser (==0.5.6)"] +events = ["jsonpath-ng"] glue = ["pyparsing (>=3.0.7)"] iotdata = ["jsondiff (>=1.1.2)"] -proxy = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=2.5.1)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.0)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"] -resourcegroupstaggingapi = ["PyYAML (>=5.1)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.0)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)"] -s3 = ["PyYAML (>=5.1)", "py-partiql-parser (==0.5.0)"] -s3crc32c = ["PyYAML (>=5.1)", "crc32c", "py-partiql-parser (==0.5.0)"] -server = ["PyYAML (>=5.1)", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "ecdsa (!=0.15)", "flask (!=2.2.0,!=2.2.1)", "flask-cors", "graphql-core", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.0)", "pyparsing (>=3.0.7)", "python-jose[cryptography] (>=3.1.0,<4.0.0)", "setuptools", "sshpubkeys (>=3.1.0)"] +proxy = ["PyYAML (>=5.1)", "antlr4-python3-runtime", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=2.5.1)", "graphql-core", "joserfc (>=0.9.0)", "jsondiff (>=1.1.2)", "jsonpath-ng", "multipart", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.6)", "pyparsing (>=3.0.7)", "setuptools"] +quicksight = ["jsonschema"] +resourcegroupstaggingapi = ["PyYAML (>=5.1)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "graphql-core", "joserfc (>=0.9.0)", "jsondiff (>=1.1.2)", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.6)", "pyparsing (>=3.0.7)"] +s3 = ["PyYAML (>=5.1)", "py-partiql-parser (==0.5.6)"] +s3crc32c = ["PyYAML (>=5.1)", "crc32c", "py-partiql-parser (==0.5.6)"] +server = ["PyYAML (>=5.1)", "antlr4-python3-runtime", "aws-xray-sdk (>=0.93,!=0.96)", "cfn-lint (>=0.40.0)", "docker (>=3.0.0)", "flask (!=2.2.0,!=2.2.1)", "flask-cors", "graphql-core", "joserfc (>=0.9.0)", "jsondiff (>=1.1.2)", "jsonpath-ng", "openapi-spec-validator (>=0.5.0)", "py-partiql-parser (==0.5.6)", "pyparsing (>=3.0.7)", "setuptools"] ssm = ["PyYAML (>=5.1)"] +stepfunctions = ["antlr4-python3-runtime", "jsonpath-ng"] xray = ["aws-xray-sdk (>=0.93,!=0.96)", "setuptools"] [[package]] @@ -4908,4 +4910,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"] [metadata] lock-version = "2.0" python-versions = "3.12.6" -content-hash = "765a9be77345778b4ca22ccbc1597e7d6946d305ed6f9bb6ade0519136df64fb" +content-hash = "61a3e8825e3f084280eac28a5f48907dee27289b1de56e04092e874ddbae71be" diff --git a/pyproject.toml b/pyproject.toml index fa90106406..6ddd614706 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ django-debug-toolbar = "^4.1.0" factory_boy = "^3.3.0" faker = "^30.0.0" ipdb = "^0.13.13" -moto = "^4.1.12" +moto = "^5.0.0" nplusone = "^1.0.0" pdbpp = "^0.10.3" pytest = "^8.0.0"