Skip to content

Commit

Permalink
Merge pull request #959 from rkingsbury/main
Browse files Browse the repository at this point in the history
update decorators for moto v5
  • Loading branch information
rkingsbury committed Jun 5, 2024
2 parents 5a502f0 + 08a9585 commit ed451a1
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ testing = [
"pytest-asyncio",
"pytest-xdist",
"pre-commit",
"moto",
"moto>=5.0", # mock_s3 changed to mock_aws in v5
"ruff",
"responses<0.22.0",
"types-pyYAML",
Expand Down
2 changes: 1 addition & 1 deletion requirements/macos-latest_py3.10_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.2
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/macos-latest_py3.11_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.2
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/macos-latest_py3.12_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.3
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/macos-latest_py3.9_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.2
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.10_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.2
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.11_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.2
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.12_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.3
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/ubuntu-latest_py3.9_extras.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ monty==2023.11.3
# via maggma (setup.py)
montydb==2.5.2
# via maggma (setup.py)
moto==4.2.11
moto==5.0.9
# via maggma (setup.py)
msal==1.26.0
# via
Expand Down
18 changes: 9 additions & 9 deletions tests/stores/test_aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import boto3
import pytest
from botocore.exceptions import ClientError
from moto import mock_s3
from moto import mock_aws
from sshtunnel import BaseSSHTunnelForwarderError

from maggma.stores import MemoryStore, MongoStore, S3Store
Expand Down Expand Up @@ -32,7 +32,7 @@ def ssh_tunnel():

@pytest.fixture()
def s3store():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand Down Expand Up @@ -64,7 +64,7 @@ def s3store():

@pytest.fixture()
def s3store_w_subdir():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand All @@ -77,7 +77,7 @@ def s3store_w_subdir():

@pytest.fixture()
def s3store_multi():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand All @@ -90,7 +90,7 @@ def s3store_multi():

@pytest.fixture()
def s3store_with_tunnel(ssh_tunnel):
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand All @@ -102,7 +102,7 @@ def s3store_with_tunnel(ssh_tunnel):


def test_keys():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")
index = MemoryStore("index", key=1)
Expand Down Expand Up @@ -306,7 +306,7 @@ def test_searchable_fields(s3store):


def test_newer_in(s3store):
with mock_s3():
with mock_aws():
tic = datetime(2018, 4, 12, 16)
tic2 = datetime.utcnow()
conn = boto3.client("s3")
Expand Down Expand Up @@ -358,7 +358,7 @@ def test_get_session(s3store):


def test_no_bucket():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand Down Expand Up @@ -431,7 +431,7 @@ def local_address(self):
return "ADDRESS", "PORT"

def get_store():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand Down
18 changes: 9 additions & 9 deletions tests/stores/test_open_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import pandas as pd
import pytest
from bson import json_util
from moto import mock_s3
from moto import mock_aws

from maggma.stores.open_data import OpenDataStore, PandasMemoryStore, S3IndexStore, TasksOpenDataStore

Expand Down Expand Up @@ -203,7 +203,7 @@ def test_pdmems_update(memstore):
@pytest.fixture()
def s3indexstore():
data = [{"task_id": "mp-1", "last_updated": datetime.utcnow()}]
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")
client = boto3.client("s3", region_name="us-east-1")
Expand Down Expand Up @@ -232,7 +232,7 @@ def test_s3is_pickle(s3indexstore):

def test_s3is_connect_retrieve_manifest(s3indexstore):
assert s3indexstore.retrieve_manifest().equals(s3indexstore._data)
with mock_s3():
with mock_aws():
with pytest.raises(s3indexstore.s3_client.exceptions.NoSuchBucket):
S3IndexStore(collection_name="foo", bucket="bucket2", key="task_id").retrieve_manifest()
with pytest.raises(RuntimeError):
Expand All @@ -247,7 +247,7 @@ def test_s3is_connect_retrieve_manifest(s3indexstore):


def test_s3is_store_manifest():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket2")
s3is = S3IndexStore(collection_name="foo", bucket="bucket2", key="task_id")
Expand Down Expand Up @@ -276,7 +276,7 @@ def test_s3is_close(s3indexstore):

@pytest.fixture()
def s3store():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand Down Expand Up @@ -309,7 +309,7 @@ def s3store():

@pytest.fixture()
def s3store_w_subdir():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")
conn.create_bucket(Bucket="bucket2")
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_read_doc_from_s3():
{"task_id": "mp-1", "last_updated": datetime.utcnow(), "group": "foo", "also_group": "boo"},
{"task_id": "mp-2", "last_updated": datetime.utcnow(), "group": "foo", "also_group": "boo"},
]
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")
client = boto3.client("s3", region_name="us-east-1")
Expand Down Expand Up @@ -560,7 +560,7 @@ def test_additional_metadata(s3store):

def test_rebuild_index_from_s3_for_tasks_store():
data = [{"task_id": "mp-2", "data": "asd", "last_updated": datetime.utcnow(), "group": {"level_two": 4}}]
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")

Expand Down Expand Up @@ -590,7 +590,7 @@ def test_rebuild_index_from_s3_for_tasks_store():


def test_no_update_for_tasks_store():
with mock_s3():
with mock_aws():
conn = boto3.resource("s3", region_name="us-east-1")
conn.create_bucket(Bucket="bucket1")
store = TasksOpenDataStore(
Expand Down

0 comments on commit ed451a1

Please sign in to comment.