diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 349ebcb..5383a66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,7 +4,42 @@ on: [push] jobs: + test: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@master + + - name: Checkout qwc-docker + uses: actions/checkout@master + with: + repository: qwc-services/qwc-docker + path: qwc-docker + + - name: Start demo database + run: | + cd qwc-docker + cp pg_service.conf ~/.pg_service.conf + sed -i 's|host=qwc-postgis|host=localhost|g' ~/.pg_service.conf + sed -i 's|port=5432|port=5439|g' ~/.pg_service.conf + sed -Ei "s|^(\s*POSTGRES_PASSWORD:).*$|\1 'waej7WuoOoth0wor'|" docker-compose-example.yml + sed -i 's|qwc-qgis-server|localhost:8001|' volumes/config/default/legendConfig.json + sed -i -e 's|# ports:|ports:|g' -e 's|# - "127.0.0.1| - "127.0.0.1|g' docker-compose-example.yml + docker-compose -f docker-compose-example.yml up -d qwc-postgis qwc-config-db-migrate qwc-qgis-server + + - name: Setting up Python + uses: actions/setup-python@v2 + with: + python-version: '3.12' + + - name: Run unittests + run: | + python -m pip install --upgrade pip + python -m pip install -r requirements.txt + PYTHONPATH=$PWD/src CONFIG_PATH=$PWD/qwc-docker/volumes/config/ python3 test.py + build: + needs: test runs-on: ubuntu-latest if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') steps: diff --git a/tests/api_tests.py b/tests/api_tests.py index 95e8c2e..ab056a2 100644 --- a/tests/api_tests.py +++ b/tests/api_tests.py @@ -1,12 +1,12 @@ import os import unittest -from urllib.parse import urlparse, parse_qs, unquote -from flask import Response, json +from flask import Response from flask.testing import FlaskClient -from flask_jwt_extended import JWTManager, create_access_token +from flask_jwt_extended import JWTManager import server +JWTManager(server.app) class ApiTestCase(unittest.TestCase): @@ -15,30 +15,24 @@ class ApiTestCase(unittest.TestCase): def setUp(self): server.app.testing = True self.app = FlaskClient(server.app, Response) - JWTManager(server.app) def tearDown(self): pass - def jwtHeader(self): - with server.app.test_request_context(): - access_token = create_access_token('test') - return {'Authorization': 'Bearer {}'.format(access_token)} - # submit query def test_print(self): params = { 'DPI': 300, 'SRS': 'EPSG:2056', - 'TEMPLATE': 'A4_portrait', + 'TEMPLATE': 'A4 Landscape', 'FORMAT': 'PDF', - 'TRANSPARENT': 1, - 'LAYERS': 'test_point,test_poly,wms:http://wms.geo.admim.ch#test', + 'TRANSPARENT': 'true', + 'LAYERS': 'countries,states_provinces,country_names,geographic_lines', 'OPACITIES': '255,127,192', 'COLORS': ',,', - 'MAP0:LAYERS': 'test_point,test_poly,wms:http://wms.geo.admim.ch#test', - 'MAP0:SCALE': 250000, - 'MAP0:EXTENT': '2600087,1219011,2618587,1243911', + 'MAP0:LAYERS': 'countries,states_provinces,country_names,geographic_lines', + 'MAP0:SCALE': 12500000, + 'MAP0:EXTENT': '-375000,4812500,2375000,7187500', 'MAP0:ROTATION': 0, 'MAP0:GRID_INTERVAL_X': 500, 'MAP0:GRID_INTERVAL_Y': 500, @@ -50,13 +44,5 @@ def test_print(self): 'MAP0:HIGHLIGHT_LABELBUFFERSIZE': '', 'MAP0:HIGHLIGHT_LABELSIZE': '' } - response = self.app.post('/somap', data=params, headers=self.jwtHeader()) + response = self.app.post('/ows/qwc_demo', data=params) self.assertEqual(200, response.status_code, "Status code is not OK") - data = json.loads(response.data) - self.assertEqual('somap_print', data['path'], 'Print project name mismatch') - self.assertEqual('POST', data['method'], 'Method mismatch') - print_params = dict([list(map(unquote, param.split("=", 1))) for param in data['data'].split("&")]) - for param in params.keys(): - self.assertTrue(param in print_params, "Parameter %s missing in response" % param) - self.assertEqual(print_params[param], str(params[param]), "Parameter %s mismatch" % param) - self.assertTrue("SLD_BODY" in print_params) diff --git a/tests/testenv.zip b/tests/testenv.zip deleted file mode 100644 index b458c0f..0000000 Binary files a/tests/testenv.zip and /dev/null differ