From 8ece53da59afb223aece5c2a3bf066d6838b6083 Mon Sep 17 00:00:00 2001 From: SHAPIRO Eitan Date: Wed, 29 Jan 2020 16:42:08 +0200 Subject: [PATCH 1/2] fix delete file scenario. Was missing normaliztion from path to absolute path --- tc_aws/aws/storage.py | 4 ++-- tc_aws/storages/s3_storage.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tc_aws/aws/storage.py b/tc_aws/aws/storage.py index 450aac5..7c6f062 100644 --- a/tc_aws/aws/storage.py +++ b/tc_aws/aws/storage.py @@ -82,12 +82,12 @@ def set(self, bytes, abspath, callback=None): ) @return_future - def remove(self, path, callback=None): + def remove(self, abspath, callback=None): """ Deletes data at path :param string path: Path to delete """ - self.storage.delete(path) + self.storage.delete(abspath) @return_future def exists(self, path, callback): diff --git a/tc_aws/storages/s3_storage.py b/tc_aws/storages/s3_storage.py index 471d2ec..3e898c6 100644 --- a/tc_aws/storages/s3_storage.py +++ b/tc_aws/storages/s3_storage.py @@ -40,6 +40,14 @@ def once_written(response): self.set(bytes, self._normalize_path(path), callback=once_written) + @return_future + def remove(self, path, callback=None): + """ + Deletes data at path + :param string path: Path to delete + """ + super(Storage, self).remove(self._normalize_path(path), callback) + @return_future def get(self, path, callback): """ From 6728e9295894da93ed99a5ba1a089a8d2c025619 Mon Sep 17 00:00:00 2001 From: eitanshapiro Date: Mon, 24 Feb 2020 15:15:57 +0200 Subject: [PATCH 2/2] adding root path is releving the remove image issue --- tests/test_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_storage.py b/tests/test_storage.py index 686294f..9427683 100644 --- a/tests/test_storage.py +++ b/tests/test_storage.py @@ -54,7 +54,7 @@ def test_can_get_image_inexistance(self): @gen_test def test_can_remove_instance(self): - config = Config(TC_AWS_STORAGE_BUCKET=s3_bucket) + config = Config(TC_AWS_STORAGE_BUCKET=s3_bucket,TC_AWS_STORAGE_ROOT_PATH='nana') storage = Storage(Context(config=config, server=get_server('ACME-SEC'))) yield storage.put(IMAGE_URL % '4', IMAGE_BYTES) yield storage.remove(IMAGE_URL % '4')