Skip to content

Commit

Permalink
Change signature to more AWS-way.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyazovetskov Vladimir committed May 28, 2022
1 parent 7f7d2fe commit 4f884cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions s3_objects_tracker/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ class ObjectWithIDProtocol(Protocol[IDT]):
class S3ObjectsTracker(Generic[IDT]):
def __init__(
self,
bucket: str,
bucket_name: str,
endpoint_url: str,
aws_access_key_id: str,
aws_secret_access_key: str,
filename: str = "data.json",
max_published_objects: int = 50,
):
self.bucket = bucket
self.bucket_name = bucket_name
self.endpoint_url = endpoint_url
self.aws_access_key_id = aws_access_key_id
self.aws_secret_access_key = aws_secret_access_key
Expand All @@ -37,7 +37,7 @@ def __init__(

async def _fetch_from_s3(self) -> None:
try:
response = await self._s3_client.get_object(Bucket=self.bucket, Key=self.filename)
response = await self._s3_client.get_object(Bucket=self.bucket_name, Key=self.filename)
except self._s3_client.exceptions.NoSuchKey:
self._published_ids = []
return
Expand All @@ -49,7 +49,7 @@ async def _upload_to_s3(self) -> None:
self._published_ids = self._published_ids[-self.max_published_objects :]
json_str = json.dumps(self._published_ids) + "\n"
await self._s3_client.put_object(
Bucket=self.bucket,
Bucket=self.bucket_name,
Key=self.filename,
Body=json_str.encode("utf-8"),
ContentType="application/json",
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def empty_object_storage_mock():
@pytest.fixture(scope="session")
def s3_credentials():
return {
"bucket": "test-bucket",
"bucket_name": "test-bucket",
"endpoint_url": "http://localhost:9000",
"aws_access_key_id": "test-access-key-id",
"aws_secret_access_key": "test-secret-access-key",
Expand Down

0 comments on commit 4f884cd

Please sign in to comment.