Repository: oussjarrousse/pytest-minio-mock (language: python)

Issue:
33 fixing get object no such key
## Change Summary
 - In `MockMinioBucket.get_object()`, when object cannot be found, raises `S3Error` with error code `NoSuchKey` instead of `404`.

## Related issue number
 - Closes #33 

## Checklist
- [x] code is ready
- [x] add tests
- [x] all tests passing
- [x] test coverage did not drop
- [x] PR is ready for review

## Additional Context

Might be a good idea to reference this part of code? 

https://github.com/minio/minio-py/blob/fd3571aa9b9402f050192ad4c6c087d2806ca9eb/minio/api.py#L378

It contains error code mapping to a more dev-friendly string. There are many other places where 3-digits error code can be replaced by string, but it depends on your decision. Cheers :)


Discussion / hints:

Fix patch:
diff --git a/setup.py b/setup.py
index 3e38d18..1a166d0 100644
--- a/setup.py
+++ b/setup.py
@@ -18,10 +18,10 @@
     author="Oussama Jarrousse",
     author_email="oussama@jarrousse.org",
     description="A pytest plugin for mocking Minio S3 interactions",
-    long_description=open("README.md").read(),
+    long_description=open("README.md", encoding="utf-8").read(),
     keywords="pytest minio mock",
     extras_require={"dev": ["pre-commit", "tox"]},
-    version="0.4.14",
+    version="0.4.15",
     long_description_content_type="text/markdown",
     classifiers=[
         "Framework :: Pytest",


Test patch:
diff --git a/pytest_minio_mock/__init__.py b/pytest_minio_mock/__init__.py
index 222f093..e838b9f 100644
--- a/pytest_minio_mock/__init__.py
+++ b/pytest_minio_mock/__init__.py
@@ -17,10 +17,10 @@
 
 __title__ = "pytest-minio-mock"
 __description__ = "A pytest plugin for mocking Minio S3 interactions"
-__version__ = "0.4.14"
+__version__ = "0.4.15"
 __status__ = "Production"
 __license__ = "MIT"
 __author__ = "Oussama Jarrousse"
 __maintainer__ = "Oussama Jarrousse"
 __email__ = "oussama@jarrousse.org"
-__credits__ = ["Gustavo Satheler", "@cottephi", "Wouter van Atteveldt"]
+__credits__ = ["Gustavo Satheler", "@cottephi", "Wouter van Atteveldt", "@KelvinHong"]
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
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