You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by bo...@apache.org on 2023/12/21 09:20:43 UTC

(streampipes) 01/02: fix(#2329): remove trailing whitespaces in URLs

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

bossenti pushed a commit to branch 2329-python-client-throws-exception-on-connection
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit b1c6e6dc478f0da2b4770cfc2a99718e696dc303
Author: bossenti <bo...@posteo.de>
AuthorDate: Thu Dec 21 09:26:29 2023 +0100

    fix(#2329): remove trailing whitespaces in URLs
---
 streampipes-client-python/streampipes/endpoint/endpoint.py | 9 +++++++--
 streampipes-client-python/tests/client/test_endpoint.py    | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/streampipes-client-python/streampipes/endpoint/endpoint.py b/streampipes-client-python/streampipes/endpoint/endpoint.py
index fa96df79a..d542a1a92 100644
--- a/streampipes-client-python/streampipes/endpoint/endpoint.py
+++ b/streampipes-client-python/streampipes/endpoint/endpoint.py
@@ -205,8 +205,13 @@ class APIEndpoint(Endpoint):
             The specified resource as an instance of the corresponding model class.
         """
 
+        query_url = f"{self.build_url()}"
+
+        if identifier:
+            query_url += f"/{identifier}"
+
         response = self._make_request(
-            request_method=self._parent_client.request_session.get, url=f"{self.build_url()}/{identifier}"
+            request_method=self._parent_client.request_session.get, url=query_url
         )
 
         return self._container_cls._resource_cls()(**response.json())
@@ -226,7 +231,7 @@ class APIEndpoint(Endpoint):
 
         self._make_request(
             request_method=self._parent_client.request_session.post,
-            url=f"{self.build_url()}/",
+            url=f"{self.build_url()}",
             data=json.dumps(resource.to_dict(use_source_names=True)),
             headers={"Content-type": "application/json"},
         )
diff --git a/streampipes-client-python/tests/client/test_endpoint.py b/streampipes-client-python/tests/client/test_endpoint.py
index c610339ee..2f63a781e 100644
--- a/streampipes-client-python/tests/client/test_endpoint.py
+++ b/streampipes-client-python/tests/client/test_endpoint.py
@@ -235,7 +235,7 @@ class TestStreamPipesEndpoints(TestCase):
         client.dataStreamApi.post(DataStream(**self.data_stream_get))
 
         http_session_mock.post.assert_called_with(
-            url="https://localhost:80/streampipes-backend/api/v2/streams/",
+            url="https://localhost:80/streampipes-backend/api/v2/streams",
             data=json.dumps(self.data_stream_get),
             headers={"Content-type": "application/json"},
         )