diff --git a/.github/workflows/analysis-coverage.yml b/.github/workflows/analysis-coverage.yml index 74fb6c69..be77346a 100644 --- a/.github/workflows/analysis-coverage.yml +++ b/.github/workflows/analysis-coverage.yml @@ -23,6 +23,7 @@ on: env: NEXTCLOUD_URL: "http://localhost:8080/index.php" APP_ID: "nc_py_api" + APP_PORT: 9009 APP_VERSION: "1.0.0" APP_SECRET: "tC6vkwPhcppjMykD1r0n9NlI95uJMBYjs5blpIcA1PAdoPDmc5qoAjaBAkyocZ6E" NC_AUTH_USER: "admin" @@ -137,10 +138,8 @@ jobs: sleep 5s php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \ --net=host --host="127.0.0.1" --expose="local" - php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \ - --daemon-config-id 1 \ - --port 9002 \ - --secret $APP_SECRET \ + php occ app_ecosystem_v2:app:register \ + "{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_id\":1,\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"port\":$APP_PORT}" \ -e --force-scopes --system-app kill -15 $(cat /tmp/_install.pid) timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null @@ -266,10 +265,8 @@ jobs: sleep 5s php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \ --net=host --host="127.0.0.1" --expose="local" - php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \ - --daemon-config-id 1 \ - --port 9002 \ - --secret $APP_SECRET \ + php occ app_ecosystem_v2:app:register \ + "{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_id\":1,\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"port\":$APP_PORT}" \ -e --force-scopes --system-app kill -15 $(cat /tmp/_install.pid) timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null @@ -388,10 +385,8 @@ jobs: sleep 5s php occ app_ecosystem_v2:daemon:register docker-install Docker unix-socket 0 0 \ --net=host --host="127.0.0.1" --expose="local" - php occ app_ecosystem_v2:app:register $APP_ID $APP_VERSION "NcPyApi" \ - --daemon-config-id 1 \ - --port 9002 \ - --secret $APP_SECRET \ + php occ app_ecosystem_v2:app:register \ + "{\"appid\":\"$APP_ID\",\"name\":\"$APP_ID\",\"daemon_config_id\":1,\"version\":\"$APP_VERSION\",\"secret\":\"$APP_SECRET\",\"port\":$APP_PORT}" \ -e --force-scopes --system-app kill -15 $(cat /tmp/_install.pid) timeout 3m tail --pid=$(cat /tmp/_install.pid) -f /dev/null diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e0c3341..7d11f3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes to this project will be documented in this file. -## [0.0.21 - 2023-06-04] +## [0.0.21 - 2023-07-04] ### Added @@ -12,6 +12,6 @@ All notable changes to this project will be documented in this file. - All input environment variables now in Upper Case. -## [0.0.20 - 2023-06-03] +## [0.0.20 - 2023-07-03] - Written from the scratch new version of the Nextcloud Python Client. Deep Alpha. diff --git a/tests/_install.py b/tests/_install.py index 8daf7a33..15fc11c4 100644 --- a/tests/_install.py +++ b/tests/_install.py @@ -1,6 +1,7 @@ +from os import environ + import uvicorn from fastapi import FastAPI -import urllib3 from nc_py_api import NextcloudApp, set_enabled_handler, ApiScope, set_scopes @@ -15,13 +16,24 @@ def enabled_handler(enabled: bool, _nc: NextcloudApp) -> str: @APP.on_event("startup") def initialization(): set_enabled_handler(APP, enabled_handler) - set_scopes(APP, { - "required": [ApiScope.SYSTEM, ApiScope.DAV, ApiScope.USER_INFO, ApiScope.USER_STATUS, - ApiScope.NOTIFICATIONS, ApiScope.WEATHER_STATUS], - "optional": [] - }) + set_scopes( + APP, + { + "required": [ + ApiScope.SYSTEM, + ApiScope.DAV, + ApiScope.USER_INFO, + ApiScope.USER_STATUS, + ApiScope.NOTIFICATIONS, + ApiScope.WEATHER_STATUS, + ], + "optional": [], + }, + ) if __name__ == "__main__": - urllib3.disable_warnings() - uvicorn.run("_install:APP", host="0.0.0.0", port=9002, log_level='trace') + app_host = environ.get("APP_HOST", "") + uvicorn.run( + "_install:APP", host=app_host if app_host else "0.0.0.0", port=int(environ["APP_PORT"]), log_level="trace" + ) diff --git a/tests/weather_status_test.py b/tests/weather_status_test.py index 311695e5..36e108cd 100644 --- a/tests/weather_status_test.py +++ b/tests/weather_status_test.py @@ -1,5 +1,6 @@ import pytest +from nc_py_api import NextcloudException from nc_py_api.weather_status import WeatherLocationMode from gfixture import NC_TO_TEST @@ -18,20 +19,31 @@ def test_get_set_location(nc): assert loc["longitude"] == 0.0 assert isinstance(loc["address"], str) assert isinstance(loc["mode"], int) - assert nc.weather_status.set_location(address="Paris, France") + try: + assert nc.weather_status.set_location(address="Paris, 75007, France") + except NextcloudException as e: + if e.status_code == 500: + pytest.skip("Some network problem on the host") + raise e from None loc = nc.weather_status.get_location() assert loc["latitude"] assert loc["longitude"] + if loc["address"].find("Unknown") != -1: + pytest.skip("Some network problem on the host") assert loc["address"].find("Paris") != -1 assert nc.weather_status.set_location(latitude=41.896655, longitude=12.488776) loc = nc.weather_status.get_location() assert loc["latitude"] == 41.896655 assert loc["longitude"] == 12.488776 + if loc["address"].find("Unknown") != -1: + pytest.skip("Some network problem on the host") assert loc["address"].find("Rom") != -1 assert nc.weather_status.set_location(latitude=41.896655, longitude=12.488776, address="Paris, France") loc = nc.weather_status.get_location() assert loc["latitude"] == 41.896655 assert loc["longitude"] == 12.488776 + if loc["address"].find("Unknown") != -1: + pytest.skip("Some network problem on the host") assert loc["address"].find("Rom") != -1 @@ -43,7 +55,9 @@ def test_get_set_location_no_lat_lon_address(nc): @pytest.mark.parametrize("nc", NC_TO_TEST) def test_get_forecast(nc): - nc.weather_status.set_location(address="Paris, France") + nc.weather_status.set_location(latitude=41.896655, longitude=12.488776) + if nc.weather_status.get_location()["address"].find("Unknown") != -1: + pytest.skip("Some network problem on the host") forecast = nc.weather_status.get_forecast() assert isinstance(forecast, list) assert forecast