Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 committed Jul 29, 2023
1 parent 6060f29 commit 325a4f9
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .docker/docker-compose.gh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3'
services:
qgis:
image: opengisch/qgis:${QGIS_TEST_VERSION}
tty: true
volumes:
- ${GITHUB_WORKSPACE}:/usr/src
24 changes: 24 additions & 0 deletions .docker/run-docker-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
#***************************************************************************
# -------------------
# begin : 2017-08-24
# git sha : :%H$
# copyright : (C) 2017 by OPENGIS.ch
# email : [email protected]
#***************************************************************************
#
#***************************************************************************
#* *
#* 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
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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 }}
19 changes: 19 additions & 0 deletions scripts/run-tests.sh
Original file line number Diff line number Diff line change
@@ -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
Empty file added tests/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions tests/test_calculation.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 325a4f9

Please sign in to comment.