From 8a9d264e9f4e9ed38a0c7d5e0d49e49ce43b9fff Mon Sep 17 00:00:00 2001 From: Sandro Mani Date: Wed, 13 Dec 2023 14:30:35 +0100 Subject: [PATCH] Enable tests --- .github/workflows/main.yml | 35 +++++++++++++++++++++++++++++++++++ tests/api_tests.py | 34 ++++++++++------------------------ tests/testenv.zip | Bin 4644 -> 0 bytes 3 files changed, 45 insertions(+), 24 deletions(-) delete mode 100644 tests/testenv.zip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 349ebcb..83625dc 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-ogc-service:9090|localhost:8001|' volumes/config/default/printConfig.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 b458c0f59be1243b96ddd47a7cefd7c9adacb998..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4644 zcmai&XEYq{y2Xc4!l)Bv^j=2I#E^&*jLr-(#0aB|61@`y(R(L|-g_4$h~5$<2vI{2 zEqVzd%E|xUFZZ0a&bsSa&wk%e`}wxl+COa#AOQ^k0JsAf&lf?hG-Dh-fdGISF#v!J zzzlG6GIw&cvUx7z=3=j>O9B95CHfe`Cz!?wjcq%)x4&K_&HB9 zd{C7UntQToG>Cdh&u8)ahBZ4YCM5snXt#?vcM9aCaFsj(g{ky#eZq%t$2=+o zr!^_8EYf^)qr)C-#SZLluqwggBDI2MW6HHK;6mt6>?eKJMz&_d@-^yYBC8P>Dl;h} z7b`_h4$sWFvob0qex@Wmy*FCFb8$J&1Z!nZOtBGX)7WLXNK7FXC3zJQkW83HTJV7# z(1*kqPbVyhFmrxRNh?d;POL&jde>LRWacByG-iorp1Ld!Tu5Em`;T0a@k|#qGw5d9v>Ibk}^{&uW zp0#=vGsx0CxSR?;yEoyFhHr7i?}hZ_QTU`{fx^+rDgp~Lw6pQr$bq9es5hw|9g#3W zP}z*aN)Vx8iQoBIX)yY;S|8Z)?#b3o2h@P0G|u2G+7$sBWwE_)J=E$b!0jL3El>7a z(<s>%$C$zsH)4HvfTg)YgMBT9|bVEzDk%23AoQ8M+rP8UD~sld|?sZ9`*gJqjV-xf~)?|4uMku6I&G)2`++qhin}6Qi=tT;P!S`zc`G zOo#1jkB52O+ZW92(x$A*;7I?rOdFi+5IW10GG{4Sk|fLKU}R(BbmPnJx6lcuxUsB+ zrEXHV%wso_xVxyD{#N+(%jY=q!6V(cIr89(H;S~#X!)@Muk}Q0pHye3)`+!xty`X( zA;OW>ZTJ$-(7@cs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