diff --git a/ecs/crm-datafetch/tests/aws/test_s3.py b/ecs/crm-datafetch/tests/aws/test_s3.py index f341cd2c..db4f1c09 100644 --- a/ecs/crm-datafetch/tests/aws/test_s3.py +++ b/ecs/crm-datafetch/tests/aws/test_s3.py @@ -1,5 +1,7 @@ import pytest -from src.aws.s3 import S3Resource +from src.aws.s3 import ConfigBucket, S3Resource +from src.system_var import environments +from src.system_var.constants import OBJECT_INFO_FILENAME, OBJECT_INFO_FOLDER @pytest.fixture @@ -40,3 +42,18 @@ class TestS3Resource: with pytest.raises(Exception) as e: S3Resource() assert e.value.args[0] == "__init__() missing 1 required positional argument: 'bucket_name'" + + +class TestConfigBucket: + + def test_get_object_info_file(self, s3_test, s3_client, bucket_name, monkeypatch): + # = bucket_name + monkeypatch.setattr('src.aws.s3.CRM_CONFIG_BUCKET', bucket_name) + monkeypatch.setattr('src.aws.s3.OBJECT_INFO_FOLDER', 'crm') + monkeypatch.setattr('src.aws.s3.OBJECT_INFO_FILENAME', 'objects.json') + s3_client.put_object(Bucket=bucket_name, Key=f'crm/objects.json', Body=b'aaaaaaaaaaaaaaa') + config_bucket = ConfigBucket() + print('*' * 50, str(config_bucket), '*' * 50) + actual = config_bucket.get_object_info_file() + print(actual) + assert actual == 'aaaaaaaaaaaaaaa'