diff --git a/.docker/docker-compose.gh.yml b/.docker/docker-compose.gh.yml new file mode 100644 index 0000000..b365764 --- /dev/null +++ b/.docker/docker-compose.gh.yml @@ -0,0 +1,7 @@ +version: '3' +services: + qgis: + image: opengisch/qgis:${QGIS_TEST_VERSION} + tty: true + volumes: + - ${GITHUB_WORKSPACE}:/usr/src diff --git a/.docker/run-docker-tests.sh b/.docker/run-docker-tests.sh new file mode 100755 index 0000000..3f02ad5 --- /dev/null +++ b/.docker/run-docker-tests.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +#*************************************************************************** +# ------------------- +# begin : 2017-08-24 +# git sha : :%H$ +# copyright : (C) 2017 by OPENGIS.ch +# email : info@opengis.ch +#*************************************************************************** +# +#*************************************************************************** +#* * +#* This program is free software; you can redistribute it and/or modify * +#* it under the terms of the GNU General Public License as published by * +#* the Free Software Foundation; either version 2 of the License, or * +#* (at your option) any later version. * +#* * +#*************************************************************************** + +set -e + +pushd /usr/src +DEFAULT_PARAMS='-v' +xvfb-run pytest-3 ${@:-`echo $DEFAULT_PARAMS`} +popd diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..3a30567 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,18 @@ +name: test + +on: + push: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + docker run -v ${GITHUB_WORKSPACE}:/src -w /src opengisch/qgis:stable sh -c 'xvfb-run pytest-3' + env: + DOCKER_IMAGE: ${{ steps.docker-build.outputs.FULL_IMAGE_NAME }} diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh new file mode 100755 index 0000000..515ffb5 --- /dev/null +++ b/scripts/run-tests.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +# Arguments are passed one to one to pytest +# +# Run all tests: +# ./scripts/run-tests.sh # Run all tests +# +# Run all test starting with test_array_ +# ./scripts/run-tests.sh -k test_array_ + +if [ -z "$QGIS_TEST_VERSION" ]; then + export QGIS_TEST_VERSION=latest # See https://hub.docker.com/r/qgis/qgis/tags/ +fi + +cd $(dirname $0)/.. +export GITHUB_WORKSPACE=$PWD # only for local execution + +docker-compose -f .docker/docker-compose.gh.yml run qgis /usr/src/.docker/run-docker-tests.sh $@ +docker-compose -f .docker/docker-compose.gh.yml rm -s -f diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_calculation.py b/tests/test_calculation.py new file mode 100644 index 0000000..e0bd995 --- /dev/null +++ b/tests/test_calculation.py @@ -0,0 +1,16 @@ +from qgis.core import QgsFeature, QgsProject, QgsRelation, QgsVectorLayer +from qgis.gui import QgsAttributeEditorContext +from qgis.PyQt.QtCore import Qt +from qgis.testing import start_app, unittest + +from pzp.calculation import CalculationDialog + +start_app() + + +class TestCalculation(unittest.TestCase): + + def test_Calculation(self): + + self.assertTrue(False) +