Skip to content

Commit

Permalink
[2/2] Upgrade direct Python dependencies (#6511)
Browse files Browse the repository at this point in the history
Require code updates to be compatible with the dependency updates
  • Loading branch information
achave11-ucsc committed Oct 23, 2024
1 parent d679623 commit 2dd0f26
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 48 deletions.
1 change: 0 additions & 1 deletion src/azul/plugins/metadata/hca/indexer/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class HCAAggregate(Aggregate):

@cached_property
def cell_count(self) -> int:
cs: JSON
return sum(cs['total_estimated_cells']
for cs in self.contents['cell_suspensions']
if cs['total_estimated_cells'] is not None)
Expand Down
11 changes: 10 additions & 1 deletion test/azul_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ class RE(str):
'The \'body\' parameter is deprecated for the \'.*\' API '
'and will be removed in .*. Instead use .*'
),
'validate_spec shortcut is deprecated. Use validate instead.',
(
'Automatically retrieving remote references can be a security vulnerability and'
' is discouraged by the JSON Schema specifications. Relying on this behavior is'
' deprecated and will shortly become an error. If you are sure you want to '
'remotely retrieve your reference and that it is safe to do so, you can find '
'instructions for doing so via referencing.Registry in the referencing '
'documentation (https://referencing.readthedocs.org).'
)
},
UserWarning: {
'https://github.com/DataBiosphere/azul/issues/2114',
Expand Down Expand Up @@ -210,7 +219,7 @@ def addPatch(self, instance: patch) -> None:
# Moto mock's stop() method has the drastic effect of resetting the
# model class attributes that are used to track model instances so that
# they can later be cleaned up when the backend is reset.
if isinstance(instance, moto.BaseMockAWS):
if isinstance(instance, moto.core.models.MockAWS):
cleanup = partial(instance.stop, remove_data=False)
else:
cleanup = instance.stop
Expand Down
4 changes: 2 additions & 2 deletions test/dynamodb_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)

from moto import (
mock_dynamodb,
mock_aws,
)
from mypy_boto3_dynamodb import (
DynamoDBClient,
Expand Down Expand Up @@ -46,7 +46,7 @@ def dynamodb(self) -> DynamoDBClient:

def setUp(self):
super().setUp()
self.addPatch(mock_dynamodb())
self.addPatch(mock_aws())
self.dynamodb.create_table(TableName=self._dynamodb_table_name(),
BillingMode='PAY_PER_REQUEST',
AttributeDefinitions=[
Expand Down
18 changes: 6 additions & 12 deletions test/health_check_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
furl,
)
from moto import (
mock_sqs,
mock_sts,
mock_aws,
)
import requests
import responses
Expand Down Expand Up @@ -86,8 +85,7 @@ def test_validation(self):
response = requests.get(str(self.base_url.set(path=('health', path))))
self.assertEqual(400, response.status_code)

@mock_sts
@mock_sqs
@mock_aws
def test_health_all_ok(self):
self._create_mock_queues()
with self._mock():
Expand All @@ -102,8 +100,7 @@ def test_health_all_ok(self):
**self._expected_progress()
}, response.json())

@mock_sts
@mock_sqs
@mock_aws
def test_health_endpoint_keys(self):
expected = {
keys: {
Expand All @@ -126,8 +123,7 @@ def test_health_endpoint_keys(self):
self.assertEqual(200, response.status_code)
self.assertEqual(expected_response, response.json())

@mock_sts
@mock_sqs
@mock_aws
def test_cached_health(self):
# No health object is available in S3 bucket, yielding an error
with self._mock():
Expand Down Expand Up @@ -180,8 +176,7 @@ def _expected_health(self,
) -> MutableJSON:
raise NotImplementedError

@mock_sts
@mock_sqs
@mock_aws
def test_elasticsearch_down(self):
self._create_mock_queues()
mock_endpoint = ('7c9f2ddb-74ca-46a3-9438-24ce1fe7050e.com', 80)
Expand All @@ -204,8 +199,7 @@ def _expected_queues(self, *, up: bool) -> MutableJSON:
}
} if up else {
'up': False,
'error': 'The specified queue does not exist for'
' this wsdl version.'
'error': 'The specified queue does not exist.'
}
for queue_name in config.all_queue_names
})
Expand Down
6 changes: 2 additions & 4 deletions test/indexer/test_health_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from moto import (
mock_sqs,
mock_sts,
mock_aws,
)

from azul.logging import (
Expand Down Expand Up @@ -39,8 +38,7 @@ def _expected_health(self,
**self._expected_progress()
}

@mock_sts
@mock_sqs
@mock_aws
def test_queues_down(self):
with self._mock():
response = self._test('/health/fast')
Expand Down
6 changes: 2 additions & 4 deletions test/indexer/test_indexer_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
one,
)
from moto import (
mock_sqs,
mock_sts,
mock_aws,
)

from azul import (
Expand Down Expand Up @@ -76,8 +75,7 @@ def setUpModule():
configure_test_logging(log)


@mock_sts
@mock_sqs
@mock_aws
class TestIndexController(DCP1IndexerTestCase, SqsTestCase):
partition_prefix_length = 0

Expand Down
12 changes: 4 additions & 8 deletions test/indexer/test_notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
)

from moto import (
mock_sqs,
mock_sts,
mock_aws,
)
import requests

Expand Down Expand Up @@ -39,8 +38,7 @@ class TestValidNotificationRequests(LocalAppTestCase,
def lambda_name(cls) -> str:
return 'indexer'

@mock_sts
@mock_sqs
@mock_aws
def test_successful_notifications(self):
self._create_mock_notifications_queue()
body = {
Expand All @@ -55,8 +53,7 @@ def test_successful_notifications(self):
self.assertEqual(202, response.status_code)
self.assertEqual('', response.text)

@mock_sts
@mock_sqs
@mock_aws
def test_invalid_notifications(self):
bodies = {
'Missing body': {},
Expand Down Expand Up @@ -108,8 +105,7 @@ def test_invalid_notifications(self):
response = self._test(body, delete, valid_auth=True)
self.assertEqual(400, response.status_code)

@mock_sts
@mock_sqs
@mock_aws
def test_invalid_auth_for_notification_request(self):
self._create_mock_notifications_queue()
body = {
Expand Down
6 changes: 2 additions & 4 deletions test/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
one,
)
from moto import (
mock_s3,
mock_sts,
mock_aws,
)
from mypy_boto3_s3.client import (
S3Client,
Expand Down Expand Up @@ -216,8 +215,7 @@ def _s3(self) -> S3Client:

def setUp(self) -> None:
super().setUp()
self.addPatch(mock_sts())
self.addPatch(mock_s3())
self.addPatch(mock_aws())

def _create_test_bucket(self, bucket_name: str):
assert config.region in get_args(BucketLocationConstraintType)
Expand Down
2 changes: 1 addition & 1 deletion test/service/test_app_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_request_logs(self):
logs = [(r.levelno, r.getMessage()) for r in logs.records]
headers = {
'host': url.netloc,
'user-agent': 'python-requests/2.32.2',
'user-agent': 'python-requests/2.32.3',
'accept-encoding': 'gzip, deflate, br',
'accept': '*/*',
'connection': 'keep-alive',
Expand Down
6 changes: 2 additions & 4 deletions test/service/test_health_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from moto import (
mock_sqs,
mock_sts,
mock_aws,
)

from azul.logging import (
Expand Down Expand Up @@ -38,8 +37,7 @@ def _expected_health(self,
**self._expected_api_endpoints(up=endpoints_up),
}

@mock_sts
@mock_sqs
@mock_aws
def test_all_api_endpoints_down(self):
self._create_mock_queues()
with self._mock(endpoints_up=False):
Expand Down
4 changes: 2 additions & 2 deletions test/service/test_manifest_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
furl,
)
from moto import (
mock_sts,
mock_aws,
)
import requests
import responses
Expand Down Expand Up @@ -150,7 +150,7 @@ def lambda_name(cls) -> str:

execution_id = b'42'

@mock_sts
@mock_aws
@mock.patch.object(AsyncManifestService, '_sfn')
@mock.patch.object(ManifestService, 'get_manifest')
@mock.patch.object(ManifestService, 'get_cached_manifest')
Expand Down
4 changes: 2 additions & 2 deletions test/service/test_source_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)

from moto import (
mock_dynamodb,
mock_aws,
)
from mypy_boto3_dynamodb.literals import (
ScalarAttributeTypeType,
Expand All @@ -23,7 +23,7 @@
)


@mock_dynamodb
@mock_aws
class TestSourceCache(DynamoDBTestCase):

def _dynamodb_table_name(self) -> str:
Expand Down
4 changes: 2 additions & 2 deletions test/service/test_version_service.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from moto import (
mock_dynamodb,
mock_aws,
)

from azul.logging import (
Expand All @@ -19,7 +19,7 @@ def setUpModule():
configure_test_logging()


@mock_dynamodb
@mock_aws
class TestVersionService(VersionTableTestCase):

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion test/test_app_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def fail():
self.assertEqual(len(azul_log.output), 3)
headers = {
'host': f'{host}:{port}',
'user-agent': 'python-requests/2.32.2',
'user-agent': 'python-requests/2.32.3',
'accept-encoding': 'gzip, deflate, br',
'accept': '*/*',
'connection': 'keep-alive'
Expand Down

0 comments on commit 2dd0f26

Please sign in to comment.