This is an automated email from the ASF dual-hosted git repository.

bossenti pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/streampipes.git


The following commit(s) were added to refs/heads/dev by this push:
     new 1ef563c8e8 fix: replace hard-coded identifier in VersionEndpoint.get() 
method (#2871)
1ef563c8e8 is described below

commit 1ef563c8e8afdfd2e4347433eb93e607908c0a57
Author: airwish <[email protected]>
AuthorDate: Fri May 17 17:43:36 2024 +0800

    fix: replace hard-coded identifier in VersionEndpoint.get() method (#2871)
    
    * fix: Replace hard-coded identifier in VersionEndpoint.get() method with 
appropriate error raising
    
    * update raise
    
    * update docstrings
    
    * Apply suggestions from code review
    
    Co-authored-by: Tim <[email protected]>
    
    * fix ci flake8
    
    ---------
    
    Co-authored-by: Tim <[email protected]>
---
 streampipes-client-python/streampipes/endpoint/api/version.py | 10 ++++++++++
 streampipes-client-python/tests/client/test_versions.py       |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/streampipes-client-python/streampipes/endpoint/api/version.py 
b/streampipes-client-python/streampipes/endpoint/api/version.py
index aa1fe0cf3a..1a319a6de5 100644
--- a/streampipes-client-python/streampipes/endpoint/api/version.py
+++ b/streampipes-client-python/streampipes/endpoint/api/version.py
@@ -109,11 +109,21 @@ class VersionEndpoint(APIEndpoint):
         identifier: str
             Not supported by this endpoint, is set to an empty string.
 
+        Raises
+        ------
+        ValueError
+            Non-empty `identifier` is not supported by this endpoint. Please 
set `identifier` to an empty string or `None`.
+
         Returns
         -------
         versions: Version
             The specified resource as an instance of the corresponding model 
class([Version][streampipes.model.resource.Version]).  # noqa: 501
         """
+        if identifier:
+            raise ValueError(
+                "Non-empty 'identifier' is not supported by this endpoint. "
+                "Please set 'identifier' to an empty string or 'None'."
+            )
 
         return super().get(identifier="")
 
diff --git a/streampipes-client-python/tests/client/test_versions.py 
b/streampipes-client-python/tests/client/test_versions.py
index 39c4535ef2..14810e99c8 100644
--- a/streampipes-client-python/tests/client/test_versions.py
+++ b/streampipes-client-python/tests/client/test_versions.py
@@ -45,3 +45,7 @@ class TestVersions(TestCase):
         )
 
         self.assertEqual("development", result.backend_version)
+
+        # Test get with non-empty identifier raises ValueError
+        with self.assertRaises(ValueError):
+            client.versionApi.get("any-incorrect-identifier")

Reply via email to