From 6c31ff800722957bd0db7de48d4a2d26bdd1bfc3 Mon Sep 17 00:00:00 2001 From: "shimoda.m@nds-tyo.co.jp" Date: Mon, 1 Aug 2022 20:02:30 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20S3=E3=81=AE=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20Config=E3=83=90=E3=82=B1=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ecs/crm-datafetch/tests/aws/test_s3.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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'