-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from axelande/adding_ci_test
Adding ci test
- Loading branch information
Showing
3 changed files
with
127 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a single version of Python | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | ||
|
||
name: Run tests | ||
|
||
on: | ||
push: | ||
pull_request: | ||
branches: | ||
- 'main' | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Pull qgis image | ||
run: docker pull qgis/qgis:stable | ||
|
||
- name: Pip install | ||
run: | | ||
docker run --name qgis_container --volume $(pwd):/app -w=/app qgis/qgis:stable sh -c "python3 -m pip install pytest-qgis --break-system-packages" | ||
docker commit qgis_container qgis_with_deps | ||
- name: Run tests | ||
run: docker run --volume $(pwd):/app -w=/app qgis_with_deps sh -c "xvfb-run -s '+extension GLX -screen 0 1024x768x24' python3 -m pytest tests -s" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from a00_qpip.plugin import Plugin | ||
|
||
|
||
class initializationCompleted: | ||
def connect(self): | ||
pass | ||
|
||
|
||
def popWidget(): | ||
return True | ||
|
||
|
||
THIS_DIR = os.path.dirname(__file__) | ||
|
||
|
||
@pytest.fixture() | ||
def plugin(qgis_iface): | ||
qgis_iface.initializationCompleted = initializationCompleted | ||
qgis_iface.messageBar().popWidget = popWidget | ||
plugin = Plugin(qgis_iface, ".") | ||
yield plugin | ||
|
||
|
||
def test_plugin_a(plugin: Plugin): | ||
plugin_a = os.path.join(THIS_DIR, "..", "test_plugins", "plugin_a") | ||
dialog, needs_gui = plugin.check_deps([plugin_a]) | ||
libs = dialog.reqs_to_install | ||
assert len(libs) == 2 | ||
assert libs[0] == "cowsay==4.0" | ||
assert needs_gui | ||
|
||
|
||
def test_plugin_b(plugin: Plugin): | ||
plugin_b = os.path.join(THIS_DIR, "..", "test_plugins", "plugin_b") | ||
dialog, needs_gui = plugin.check_deps([plugin_b]) | ||
libs = dialog.reqs_to_install | ||
assert len(libs) == 2 | ||
assert libs[0] == "cowsay==5.0" | ||
assert needs_gui |