Skip to content

Commit

Permalink
add key to provider in repr, and add repr test
Browse files Browse the repository at this point in the history
  • Loading branch information
JJ11teen committed May 15, 2021
1 parent f4f6a5d commit f004513
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cloudmappings/storageproviders/awss3.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(
self._bucket_name = bucket_name

def safe_name(self) -> str:
return "AWSS3," f"BucketName={self._bucket_name}"
return "CloudStorageProvider=AWSS3," f"BucketName={self._bucket_name}"

def create_if_not_exists(self, metadata: Dict[str, str]):
bucket = boto3.resource("s3").Bucket(self._bucket_name)
Expand Down
2 changes: 1 addition & 1 deletion src/cloudmappings/storageproviders/azureblobstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(

def safe_name(self) -> str:
return (
"AzureBlobStorage,"
"CloudStorageProvider=AzureBlobStorage,"
f"StorageAccountName={self._container_client.account_name},"
f"ContainerName={self._container_client.container_name}"
)
Expand Down
6 changes: 5 additions & 1 deletion src/cloudmappings/storageproviders/googlecloudstorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ def __init__(
)

def safe_name(self) -> str:
return "GoogleCloudStorage," f"Project={self._client.project}," f"BucketName={self._bucket.name}"
return (
"CloudStorageProvider=GoogleCloudStorage,"
f"Project={self._client.project},"
f"BucketName={self._bucket.name}"
)

def create_if_not_exists(self, metadata: Dict[str, str]):
exists = False
Expand Down
14 changes: 14 additions & 0 deletions tests/tests/2_cloudstoragemapping_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,17 @@ def test_length(self, cloud_mapping):

cloud_mapping["c"] = b"three"
assert len(cloud_mapping) == 3

def test_repr(self, cloud_mapping):
_repr = str(cloud_mapping)

assert "CloudStorageProvider=" in _repr

if "Azure" in _repr:
assert "StorageAccountName=" in _repr
assert "ContainerName=" in _repr
elif "Google" in _repr:
assert "Project=" in _repr
assert "BucketName=" in _repr
elif "AWS" in _repr:
assert "BucketName=" in _repr

0 comments on commit f004513

Please sign in to comment.