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

bossenti pushed a commit to branch 
1259-verify-authentication-on-startup-of-python-client
in repository https://gitbox.apache.org/repos/asf/streampipes.git

commit d503def4a15b753ee6bdcb88435a296e06ab4283
Author: bossenti <[email protected]>
AuthorDate: Mon Feb 27 22:17:39 2023 +0100

    chore: remove now outdated `describe()` method
    
    Signed-off-by: bossenti <[email protected]>
---
 ...introduction-to-streampipes-python-client.ipynb | 44 -------------------
 .../streampipes/client/client.py                   | 37 ----------------
 .../tests/client/test_client.py                    | 49 ----------------------
 3 files changed, 130 deletions(-)

diff --git 
a/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb
 
b/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb
index 9c6df65b9..bc72d4174 100644
--- 
a/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb
+++ 
b/streampipes-client-python/docs/examples/1-introduction-to-streampipes-python-client.ipynb
@@ -183,43 +183,6 @@
   {
    "cell_type": "markdown",
    "source": [
-    "That's already it. You can check if everything works out by using the 
following command:"
-   ],
-   "metadata": {
-    "collapsed": false
-   }
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 6,
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "2023-02-24 17:05:49,398 - streampipes.endpoint.endpoint - [INFO] - 
[endpoint.py:167] [_make_request] - Successfully retrieved all resources.\n",
-      "2023-02-24 17:05:49,457 - streampipes.endpoint.endpoint - [INFO] - 
[endpoint.py:167] [_make_request] - Successfully retrieved all resources.\n",
-      "\n",
-      "Hi there!\n",
-      "You are connected to a StreamPipes instance running at 
http://localhost:80.\n";,
-      "The following StreamPipes resources are available with this client:\n",
-      "1x DataLakeMeasures\n",
-      "1x DataStreams\n"
-     ]
-    }
-   ],
-   "source": [
-    "client.describe()"
-   ],
-   "metadata": {
-    "collapsed": false
-   }
-  },
-  {
-   "cell_type": "markdown",
-   "source": [
-    "This prints you a short textual description of the connected StreamPipes 
instance to the console.\n",
-    "\n",
     "<br>\n",
     "\n",
     "The created `client` instance serves as the central point of interaction 
for StreamPipes.\n",
@@ -238,13 +201,6 @@
    "metadata": {
     "collapsed": false
    }
-  },
-  {
-   "cell_type": "markdown",
-   "source": [],
-   "metadata": {
-    "collapsed": false
-   }
   }
  ],
  "metadata": {
diff --git a/streampipes-client-python/streampipes/client/client.py 
b/streampipes-client-python/streampipes/client/client.py
index 65b972aff..9f24dbd58 100644
--- a/streampipes-client-python/streampipes/client/client.py
+++ b/streampipes-client-python/streampipes/client/client.py
@@ -34,7 +34,6 @@ from streampipes.endpoint.api import (
     DataStreamEndpoint,
     VersionEndpoint,
 )
-from streampipes.endpoint.endpoint import APIEndpoint
 
 logger = logging.getLogger(__name__)
 
@@ -183,39 +182,3 @@ class StreamPipesClient:
             f"{self.client_config.host_address}:"
             f"{self.client_config.port}/streampipes-backend/"
         )
-
-    def describe(self) -> None:
-        """Prints short description of the connected StreamPipes instance and 
the available resources to the console.
-
-        Returns
-        -------
-            None
-        """
-
-        # get all endpoints of this client
-        available_endpoints = [
-            attr_name for attr_name in dir(self) if 
isinstance(self.__getattribute__(attr_name), APIEndpoint)
-        ]
-
-        # collect the number of available resources per endpoint
-        endpoint_stats = {
-            (all_items := 
self.__getattribute__(endpoint_name).all()).__class__.__name__: len(all_items)
-            for endpoint_name in available_endpoints
-        }
-
-        # sort the endpoints descending based on the number of resources
-        sorted_endpoint_stats = {
-            key: val for key, val in sorted(endpoint_stats.items(), key=lambda 
item: item[1], reverse=True)
-        }
-
-        base_message = (
-            f"\nHi there!\n"
-            f"You are connected to a StreamPipes instance running at "
-            f"{'http://' if self.client_config.https_disabled else 'https://'}"
-            f"{self.client_config.host_address}:{self.client_config.port}.\n"
-            f"The following StreamPipes resources are available with this 
client:\n"
-        )
-
-        endpoint_stats_message = "\n".join(f"{count}x {name}" for name, count 
in sorted_endpoint_stats.items())
-
-        print(base_message + endpoint_stats_message)
diff --git a/streampipes-client-python/tests/client/test_client.py 
b/streampipes-client-python/tests/client/test_client.py
index b5b6448fb..20a600e7a 100644
--- a/streampipes-client-python/tests/client/test_client.py
+++ b/streampipes-client-python/tests/client/test_client.py
@@ -14,10 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-import json
-from collections import namedtuple
 from unittest import TestCase
-from unittest.mock import MagicMock, call, patch
 
 from streampipes.client import StreamPipesClient
 from streampipes.client.config import StreamPipesClientConfig
@@ -70,49 +67,3 @@ class TestStreamPipesClient(TestCase):
         )
         self.assertTrue(isinstance(result.dataLakeMeasureApi, 
DataLakeMeasureEndpoint))
         self.assertEqual(result.base_api_path, 
"https://localhost:443/streampipes-backend/";)
-
-    @patch("builtins.print")
-    @patch("streampipes.endpoint.endpoint.APIEndpoint._make_request", 
autospec=True)
-    def test_client_describe(self, make_request: MagicMock, mocked_print: 
MagicMock):
-        def simulate_response(*args, **kwargs):
-            Response = namedtuple("Response", ["text"])
-            if "measurements" in kwargs["url"]:
-                return Response(
-                    json.dumps(
-                        [
-                            {
-                                "measureName": "test",
-                                "timestampField": "time",
-                                "pipelineIsRunning": False,
-                                "schemaVersion": "0",
-                            }
-                        ]
-                    )
-                )
-            if "streams" in kwargs["url"]:
-                return Response(
-                    json.dumps(
-                        [{"elementId": "test-stream", "name": "test", 
"eventGrounding": {"transportProtocols": []}}]
-                    )
-                )
-
-        make_request.side_effect = simulate_response
-        StreamPipesClient.create(
-            client_config=StreamPipesClientConfig(
-                
credential_provider=StreamPipesApiKeyCredentials(username="user", 
api_key="key"),
-                host_address="localhost",
-                https_disabled=False,
-                port=443,
-            )
-        ).describe()
-
-        mocked_print.assert_has_calls(
-            calls=[
-                call(
-                    "\nHi there!\nYou are connected to a StreamPipes instance 
running at https://localhost:443.\n";
-                    "The following StreamPipes resources are available with 
this client:\n"
-                    "1x DataLakeMeasures\n1x DataStreams"
-                ),
-            ],
-            any_order=True,
-        )

Reply via email to