diff --git a/README.md b/README.md index 2e0245e773f509a0b95a7d351d0fba44d4616a32..ff98fd4b9762fee5e8cf28ea38633d3f43fb009f 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ This repo should be used to construct a Python server compliant to the ARF World |:-:|:--------------:|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | 📂 | openapi | A git submodule (ForgeETSI ) pointing to the repo containing the API specification file | | 📂 | client | The folder where the python code will be generated, the openapi generator is set to not overwrite some files used to test the client system | +| 📂 | client/ETSI-ARF | Folder with a python script to test the availibility of a World Storage | ## Requirements @@ -63,27 +64,31 @@ Open a command shell and execute: npx openapi-generator-cli generate ``` -# Use client within a Docker +## Installing the python module on your local computer -## Creating the python docker ## +It's recommended to create the enviroment with conda (if available) -tbd - -open a command shell and generate docker by executing: ``` - build-iis-docker-ws.bat +conda create -n openapi +conda activate openapi ``` -## How to start (with Docker-Compose) -The easiest way is to use docker-compose: +Install the World Storage OpenAPI: -Open a command shell and use docker-compose (if necessary adapt docker-compose.yml) by executing`: ``` - docker-compose.bat +cd client\generated +pip install . ``` -## How to stop -Open a command shell by executing in `server/worldstorage/src/ETSI.ARF.OpenAPI.WorldStorage`: +## Running the test script + +If using conda, activate first enviroment: ``` - docker-compose down +conda activate openapi +``` + +Run python script with: ``` +cd client\ETSI-ARF +python WorldServerTest.py +``` \ No newline at end of file diff --git a/client/ETSI-ARF/WorldServerTest.py b/client/ETSI-ARF/WorldServerTest.py new file mode 100644 index 0000000000000000000000000000000000000000..c0796245346540587b60dd924149a78ec2b87ccf --- /dev/null +++ b/client/ETSI-ARF/WorldServerTest.py @@ -0,0 +1,89 @@ +# +# ARF - Augmented Reality Framework (ETSI ISG ARF) +# +# Copyright 2024 ETSI +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Last change: Mai 2024 +# + +import time +import openapi_client +from openapi_client.api import default_api +from pprint import pprint + +# recommended to create enviroment +# conda create -n openapi +# conda activate openapi +# to install the World Storage OpenAPI: cd to /CHANGE_PATH/generated folder, and then run "pip install ." + +# then to run, activate first enviroment: +# conda activate openapi +# and then run python script: +# python <this script>.py + + +# See configuration.py for a list of all supported configuration parameters. +configuration = openapi_client.Configuration( + host="https://etsi.hhi.fraunhofer.de/" +) + +print() +print("ETSI ISG - ARF World Storage") +print() +print("Simple request tests") +print("====================") +print() +print("Using WS server" + configuration.host) +print() + +success = 0 + +# Enter a context with an instance of the API client +with openapi_client.ApiClient(configuration) as api_client: + # Create an instance of the API class + api_instance = default_api.DefaultApi(api_client) + + # example, this endpoint has no required or optional parameters + try: + # Test the server availability. + api_response = api_instance.get_ping() + print("Sending 'ping', got response: " + api_response) + success += 1 + except openapi_client.ApiException as e: + print("Exception when calling DefaultApi->get_ping: %s\n" % e) + + # example, this endpoint has no required or optional parameters + try: + # Test the server availability. + api_response = api_instance.get_version() + print("Sending 'version', got response: " + api_response) + success += 1 + except openapi_client.ApiException as e: + print("Exception when calling DefaultApi->get_ping: %s\n" % e) + + # example, this endpoint has no required or optional parameters + try: + # Test the server availability. + api_response = api_instance.get_admin() + print("Sending 'admin', got response: " + api_response) + success += 1 + except openapi_client.ApiException as e: + print("Exception when calling DefaultApi->get_ping: %s\n" % e) + +if success == 3: + print ("Connection was succesfull.") +else: + print ("Connection was not succesfull!") +