From f1815c55eababf60b270ceb92beed6e6fdc349e4 Mon Sep 17 00:00:00 2001 From: KelvinHong <34021827+KelvinHong@users.noreply.github.com> Date: Thu, 23 May 2024 21:15:43 +0800 Subject: [PATCH 1/2] Change Bucket get_object 404 to NoSuchKey. --- pytest_minio_mock/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest_minio_mock/plugin.py b/pytest_minio_mock/plugin.py index 0dcfb4a..c3745b0 100644 --- a/pytest_minio_mock/plugin.py +++ b/pytest_minio_mock/plugin.py @@ -503,7 +503,7 @@ def get_object(self, object_name, version_id): request_id=None, host_id=None, response="mocked_response", - code=404, + code="NoSuchKey", bucket_name=self.bucket_name, object_name=object_name, ) from exc From 85ed555cd027c7a5f3cbcb138351bcf7a1206d85 Mon Sep 17 00:00:00 2001 From: KelvinHong <34021827+KelvinHong@users.noreply.github.com> Date: Thu, 23 May 2024 21:17:37 +0800 Subject: [PATCH 2/2] test: Check against NoSuchKey --- tests/test_minio_mock.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_minio_mock.py b/tests/test_minio_mock.py index b6f6034..519bff8 100644 --- a/tests/test_minio_mock.py +++ b/tests/test_minio_mock.py @@ -83,7 +83,7 @@ def test_remove_bucket(minio_mock): @pytest.mark.API @pytest.mark.FUNC -def test_putting_and_removing_objects_no_versionning(minio_mock): +def test_putting_and_removing_objects_no_versioning(minio_mock): # simple thing bucket_name = "test-bucket" object_name = "test-object" @@ -110,7 +110,8 @@ def test_putting_and_removing_objects_no_versionning(minio_mock): # test retrieving object after it has been removed with pytest.raises(S3Error) as error: _ = client.get_object(bucket_name, object_name) - assert "The specified key does not exist" in str(error.value) + assert error.value.message == "The specified key does not exist." + assert error.value.code == "NoSuchKey" @pytest.mark.API