This repository was archived by the owner on Mar 23, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Remove Boto resource fixtures #8674
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a70fddc
Remove create_boto_client fixture
viren-nadkarni 4140f20
Remove s3_resource fixture
viren-nadkarni 1e17f38
Merge branch 'master' into remove-boto-resource
viren-nadkarni 49defab
Use modern fixtures in KMS tests
viren-nadkarni 83c0991
Remove use of dynamodb_resource fixture
viren-nadkarni f99f3bf
Migrate Dynamodb tests from boto_resource to aws_client
viren-nadkarni ff5beea
Remove boto resource based fixtures entirely
viren-nadkarni 5f6567f
Fixes
viren-nadkarni 6672d0d
Update snapshots
viren-nadkarni 1bdc40d
Fixes
viren-nadkarni 5f54c6a
Update snapshot transformers
viren-nadkarni c08101d
Update snapshots
viren-nadkarni 5701d33
Merge branch 'master' into remove-boto-resource
viren-nadkarni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import re | ||
| import socket | ||
| import threading | ||
| import warnings | ||
| from functools import lru_cache | ||
| from typing import Dict, Optional, Union | ||
|
|
||
|
|
@@ -226,6 +227,10 @@ def connect_to_resource( | |
| """ | ||
| Generic method to obtain an AWS service resource using boto3, based on environment, region, or custom endpoint_url. | ||
| """ | ||
| warnings.warn( | ||
| "`connect_to_resource` is obsolete. Use `localstack.aws.connect`", DeprecationWarning | ||
| ) | ||
|
|
||
| return connect_to_service( | ||
| service_name, | ||
| client=False, | ||
|
|
@@ -248,6 +253,11 @@ def connect_to_resource_external( | |
| """ | ||
| Generic method to obtain an AWS service resource using boto3, based on environment, region, or custom endpoint_url. | ||
| """ | ||
| warnings.warn( | ||
| "`connect_to_resource_external` is obsolete. Use `localstack.aws.connect`", | ||
| DeprecationWarning, | ||
| ) | ||
|
|
||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With this PR, these utilities are no longer used in the codebase but I've added these warnings so that they're properly highlighted in the IDE. Btw, Python 3.12 will have a decorator to do exactly this https://peps.python.org/pep-0702/ |
||
| return create_external_boto_client( | ||
| service_name, | ||
| client=False, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,6 @@ | |
| def test_rest_api_to_dynamodb_integration( | ||
| ddb_action, | ||
| dynamodb_create_table, | ||
| dynamodb_resource, | ||
| create_rest_api_with_integration, | ||
| snapshot, | ||
| aws_client, | ||
|
|
@@ -45,10 +44,9 @@ def test_rest_api_to_dynamodb_integration( | |
| table_name = table["TableName"] | ||
|
|
||
| # insert items | ||
| dynamodb_table = dynamodb_resource.Table(table_name) | ||
| item_ids = ("test", "test2", "test 3") | ||
| for item_id in item_ids: | ||
| dynamodb_table.put_item(Item={"id": item_id}) | ||
| aws_client.dynamodb.put_item(TableName=table_name, Item={"id": {"S": item_id}}) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The client needs the items to be typed. The Boto resource had an intrinsic type conversion so it wasn't necessary earlier |
||
|
|
||
| # construct request mapping template | ||
| if ddb_action == "PutItem": | ||
|
|
@@ -97,8 +95,8 @@ def _invoke_with_retries(id_param=None): | |
| if ddb_action == "PutItem": | ||
| result = _invoke_with_retries("test-new") | ||
| snapshot.match("result-put-item", result) | ||
| result = dynamodb_table.scan() | ||
| result["Items"] = sorted(result["Items"], key=lambda x: x["id"]) | ||
| result = aws_client.dynamodb.scan(TableName=table_name) | ||
| result["Items"] = sorted(result["Items"], key=lambda x: x["id"]["S"]) | ||
| snapshot.match("result-scan", result) | ||
|
|
||
| elif ddb_action == "Query": | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new fixture replaces the functionality offered by the Boto S3 Resource
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably prefer this to be a normal utility over a fixture but should be ok to leave as-is for now 👍