Skip to content

Commit

Permalink
CI: Fix .gitlab-ci config
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarteau committed Sep 20, 2024
1 parent bd0cde6 commit 251ef6c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ stages:
tags:
- factory-plain
variables:
ASYNC_TEST_TIMEOUT: 20.0
ASYNC_TEST_TIMEOUT: "20.0"

tests:ltr:
extends: .tests
Expand Down
2 changes: 1 addition & 1 deletion pyqgisserver/utils/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def start_qgis_application(
enable_processing: bool = False, verbose: bool = False,
cleanup: bool = True,
logger: Optional[logging.Logger] = None,
logprefix: str = 'Qgis:'
logprefix: str = 'Qgis:',
) -> qgis.core.QgsApplication:
""" Start qgis application
Expand Down
42 changes: 34 additions & 8 deletions tests/unittests/test_getfeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,34 @@ def get_app(self) -> None:
def test_getfeature_nolimit(self):
""" Test getcapabilities hrefs
"""
rv = self.client.get("?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure")
rv = self.client.get(
"?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure",
)
assert rv.status_code == 200
assert rv.headers['Content-Type'].startswith('text/xml;')

features = rv.xml.findall(".//gml:featureMember", NAMESPACES)
assert len(features) == 4

def test_getfeature_nolimit_geojson(self):
""" Test getcapabilities hrefs
"""
rv = self.client.get(
"?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure"
"&OUTPUTFORMAT=GeoJSON",
)
assert rv.status_code == 200
assert rv.headers['Content-Type'].startswith('application/vnd.geo+json;')

content = rv.json()

# print("\ntest_getfeature_nolimit_geojson", content)

assert content.get('type') == "FeatureCollection"
assert len(content["features"]) == 4


class Tests2(HTTPTestCase):

Expand All @@ -39,8 +59,10 @@ def test_getfeature_limit(self):

assert confservice.getint('server', 'getfeaturelimit') == 2

rv = self.client.get("?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure")
rv = self.client.get(
"?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure",
)
assert rv.status_code == 200
assert rv.headers['Content-Type'].startswith('text/xml;')

Expand All @@ -53,8 +75,10 @@ def test_getfeature_limit_ok(self):

assert confservice.getint('server', 'getfeaturelimit') == 2

rv = self.client.get("?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure&MAXFEATURES=1")
rv = self.client.get(
"?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure&MAXFEATURES=1",
)
assert rv.status_code == 200
assert rv.headers['Content-Type'].startswith('text/xml;')

Expand All @@ -66,8 +90,10 @@ def test_getfeature_limit_not_ok(self):
"""
assert confservice.getint('server', 'getfeaturelimit') == 2

rv = self.client.get("?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure&MAXFEATURES=3")
rv = self.client.get(
"?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetFeature&VERSION=1.0.0"
"&TYPENAME=france_parts_bordure&MAXFEATURES=3",
)
assert rv.status_code == 200
assert rv.headers['Content-Type'].startswith('text/xml;')

Expand Down
33 changes: 33 additions & 0 deletions tests/unittests/test_getlegendgraphic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""
Test Getfeature requests
"""
import pytest

from pyqgisserver.tests import HTTPTestCase

xlink = "{http://www.w3.org/1999/xlink}"


class Tests(HTTPTestCase):

@pytest.mark.skip(reason="Wait for proper datasource")
def test_getlegendgraphic_xml(self):
""" Test getlegendgraphic
"""
rv = self.client.get(
"?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetLegendGraphic&VERSION=1.0.0"
"&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=france_parts_bordure",
)
assert rv.status_code == 200
assert rv.headers['Content-Type'].startswith('text/xml;')

@pytest.mark.skip(reason="Wait for proper datasource")
def test_getlegendgraphic_json(self):
""" Test getlegendgraphic in json format
"""
rv = self.client.get(
"?MAP=france_parts.qgs&SERVICE=WFS&REQUEST=GetLegendGraphic&VERSION=1.0.0"
"&FORMAT=json&WIDTH=20&HEIGHT=20&LAYER=france_parts_bordure",
)
assert rv.status_code == 200
assert rv.headers['Content-Type'].startswith('text/xml;')

0 comments on commit 251ef6c

Please sign in to comment.