Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR-6090: Use ~= instead of == in Python requirements files #294

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
boto3==1.20.54
hypothesis==6.39.1
moto==3.0.3
pytest-cov==3.0.0
pytest-mock==3.7.0
pytest==7.0.1
boto3==1.35.18
hypothesis==6.112.0
moto==5.0.14
pytest-cov==5.0.0
pytest-mock==3.14.0
pytest==8.3.3
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cachetools==5.0.0
jinja2>=3.0.0
netaddr>=0.8.0
pyjwt[crypto]>=1.6.0
pyyaml>=5.1
cachetools~=5.0
jinja2~=3.0
netaddr~=1.0
pyjwt[crypto]~=2.0
pyyaml~=6.0

pip>=19.2 # not directly required, pinned by Snyk to avoid a vulnerability
pip~=24.0 # not directly required, pinned by Snyk to avoid a vulnerability
38 changes: 20 additions & 18 deletions tests/test_aws_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import boto3
import botocore
import moto
import pytest
from moto import mock_aws
from netaddr import IPNetwork

from rain_api_core.aws_util import (
Expand Down Expand Up @@ -38,15 +38,15 @@ def test_get_region_cache(mock_region_name):
mock_region_name.assert_called_once()


@moto.mock_secretsmanager
@mock_aws
def test_retrieve_secret():
client = boto3.client("secretsmanager")
client.create_secret(Name="secret_name", SecretString='{"foo": "bar"}')

assert retrieve_secret("secret_name") == {"foo": "bar"}


@moto.mock_secretsmanager
@mock_aws
def test_retrieve_secret_binary():
client = boto3.client("secretsmanager")
client.create_secret(Name="binary_secret_name", SecretBinary=b"foobar")
Expand All @@ -66,20 +66,20 @@ def test_retrieve_secret_cached(mock_botosess):
client.get_secret_value.assert_called_once()


@moto.mock_secretsmanager
@mock_aws
def test_retrieve_secret_nonexistent():
with pytest.raises(botocore.exceptions.ClientError):
assert retrieve_secret("does_not_exist") == {"foo": "bar"}


@moto.mock_s3
@mock_aws
def test_get_s3_resource_cached(monkeypatch):
monkeypatch.setenv("S3_SIGNATURE_VERSION", "v2")

assert get_s3_resource() is get_s3_resource()


@moto.mock_s3
@mock_aws
def test_read_s3():
resource = boto3.resource("s3")
bucket = resource.Bucket("test_bucket")
Expand All @@ -90,15 +90,15 @@ def test_read_s3():
assert read_s3("test_bucket", "test_file") == "foobar"


@moto.mock_s3
@mock_aws
def test_read_s3_nonexistent():
resource = boto3.resource("s3")

with pytest.raises(botocore.exceptions.ClientError):
assert read_s3("nonexistent", "test_file", resource)


@moto.mock_s3
@mock_aws
def test_get_yaml(data):
resource = boto3.resource("s3")
bucket = resource.Bucket("test_bucket")
Expand All @@ -109,13 +109,13 @@ def test_get_yaml(data):
assert get_yaml("test_bucket", "sample.yaml") == {"key": ["value1", "value2"]}


@moto.mock_s3
@mock_aws
def test_get_yaml_nonexistent():
with pytest.raises(botocore.exceptions.ClientError):
assert get_yaml("nonexistent", "sample.yaml")


@moto.mock_s3
@mock_aws
def test_get_yaml_file(data):
resource = boto3.resource("s3")
bucket = resource.Bucket("test_bucket")
Expand All @@ -126,14 +126,14 @@ def test_get_yaml_file(data):
assert get_yaml_file("test_bucket", "sample.yaml") == {"key": ["value1", "value2"]}


@moto.mock_s3
@mock_aws
def test_get_yaml_file_nonexistent():
assert get_yaml_file("nonexistent", "") == {}
with pytest.raises(botocore.exceptions.ClientError):
get_yaml_file("nonexistent", "sample.yaml")


@moto.mock_sts
@mock_aws
def test_get_role_creds(monkeypatch):
monkeypatch.setenv("EGRESS_APP_DOWNLOAD_ROLE_ARN", "egress_app_download_role_arn")
monkeypatch.setitem(role_creds_cache, "egress_app_download_role_arn", {})
Expand All @@ -153,17 +153,19 @@ def test_get_role_creds(monkeypatch):
"PackedPolicySize": 6,
"ResponseMetadata": {
"HTTPHeaders": {
"server": "amazon.com"
"date": mock.ANY,
"server": "amazon.com",
"x-amzn-requestid": mock.ANY,
},
"HTTPStatusCode": 200,
"RequestId": "c6104cbe-af31-11e0-8154-cbc7ccf896c7",
"RetryAttempts": 0
}
"RequestId": mock.ANY,
"RetryAttempts": 0,
},
}
assert session_offset == 0


@moto.mock_sts
@mock_aws
@mock.patch(f"{MODULE}.time", autospec=True)
def test_get_role_creds_cached(mock_time, monkeypatch):
monkeypatch.setenv("EGRESS_APP_DOWNLOAD_ROLE_ARN", "egress_app_download_role_arn")
Expand All @@ -182,7 +184,7 @@ def test_get_role_creds_cached(mock_time, monkeypatch):
assert session1 != session3


@moto.mock_sts
@mock_aws
def test_get_role_session_cached(monkeypatch):
monkeypatch.setenv("EGRESS_APP_DOWNLOAD_ROLE_ARN", "egress_app_download_role_arn")
monkeypatch.setitem(role_creds_cache, "egress_app_download_role_arn", {})
Expand Down
12 changes: 6 additions & 6 deletions tests/test_view_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import boto3
import jwt
import moto
import pytest
from hypothesis import assume, given, note
from hypothesis import strategies as st
from moto import mock_aws

from rain_api_core.view_util import (
TemplateManager,
Expand Down Expand Up @@ -71,7 +71,7 @@ def test_get_jwt_keys_error(mock_retrieve_secret):
_ = get_jwt_keys()


@moto.mock_s3
@mock_aws
def test_download_templates(local_cachedir):
bucket = "test_bucket"
template_dir = "templates/"
Expand All @@ -90,7 +90,7 @@ def test_download_templates(local_cachedir):
assert f.read() == contents


@moto.mock_s3
@mock_aws
def test_download_templates_none_available(local_cachedir):
bucket = "test_bucket"
client = boto3.client("s3")
Expand All @@ -102,15 +102,15 @@ def test_download_templates_none_available(local_cachedir):
assert list(local_cachedir.iterdir()) == []


@moto.mock_s3
@mock_aws
def test_download_templates_missing_bucket(local_cachedir):
manager = TemplateManager("does_not_exist", "templates", cache_dir=local_cachedir)
manager.download_templates()

assert list(local_cachedir.iterdir()) == []


@moto.mock_s3
@mock_aws
def test_download_templates_missing_template_dir(local_cachedir):
manager = TemplateManager("does_not_exist", "", cache_dir=local_cachedir)
manager.download_templates()
Expand All @@ -132,7 +132,7 @@ def test_render_missing_template(template_dir):
assert rendered == "Cannot find the HTML template directory"


@moto.mock_s3
@mock_aws
def test_render_wait_for_templates(local_cachedir):
bucket = "test_bucket"
template_dir = "templates/"
Expand Down
Loading