-
Notifications
You must be signed in to change notification settings - Fork 11
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 #86 from MIERUNE/testing
testing
- Loading branch information
Showing
13 changed files
with
414 additions
and
60 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,4 @@ | ||
[report] | ||
omit = | ||
tests/* | ||
/usr/lib/python3/dist-packages/* |
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,35 @@ | ||
name: Test | ||
|
||
on: | ||
pull_request: | ||
branches: [main] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
qgis_image_tag: [release-3_28] | ||
env: | ||
OS: ubuntu | ||
QGIS_IMAGE_TAG: ${{ matrix.qgis_image_tag }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Pull QGIS | ||
run: docker pull qgis/qgis:${{ matrix.qgis_image_tag }} | ||
|
||
- name: Export requirements.txt | ||
run: | | ||
pip3 install poetry | ||
poetry export --with dev -f requirements.txt -o requirements.txt | ||
- name: Run tests | ||
run: docker run --rm --net=host --volume .:/app -w=/app -e QGIS_PLUGIN_IN_CI=1 qgis/qgis:${{ matrix.qgis_image_tag }} sh -c "pip3 install -r /app/requirements.txt && xvfb-run -s '+extension GLX -screen 0 1024x768x24' pytest -v --cov --cov-report=xml --cov-report=term" | ||
|
||
- name: Upload coverage reports to Codecov | ||
uses: codecov/[email protected] | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
slug: MIERUNE/GTFS-GO |
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 |
---|---|---|
|
@@ -2,3 +2,8 @@ | |
Desktop.ini | ||
__pycache__/ | ||
.venv/ | ||
.coverage | ||
coverage.xml | ||
.pytest_cache/ | ||
.ruff_cache/ | ||
requirements.txt |
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
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -6,12 +6,18 @@ authors = ["Kanahiro <[email protected]>"] | |
readme = "README.md" | ||
|
||
[tool.poetry.dependencies] | ||
python = "^3.7" | ||
python = "^3.9" | ||
|
||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^7.2.1" | ||
ruff = "^0.4.3" | ||
pytest-qt = "^4.4.0" | ||
pytest-cov = "^5.0.0" | ||
pandas = "^2.2.2" | ||
pytest-mock = "^3.14.0" | ||
pytest-qgis = "^2.0.0" | ||
|
||
|
||
[build-system] | ||
requires = ["poetry-core"] | ||
|
Empty file.
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,22 @@ | ||
from typing import Iterable | ||
|
||
import pytest | ||
from pytest_mock import MockerFixture | ||
from qgis.gui import QgisInterface | ||
from qgis.PyQt.QtCore import QSettings | ||
|
||
from ..__init__ import classFactory | ||
|
||
|
||
@pytest.fixture() | ||
def plugin(qgis_iface: QgisInterface, mocker: MockerFixture) -> Iterable[None]: | ||
# mock | ||
mocker.patch.object(QSettings, "value", return_value="en") | ||
qgis_iface.addPluginToWebMenu = lambda x, y: None # pytest-qgisで未実装 | ||
|
||
_plugin = classFactory(qgis_iface) | ||
_plugin.initGui() | ||
|
||
yield _plugin | ||
|
||
# _plugin.unload() QgisInterface.removePluginMenu()がpytest-qgisで未実装 |
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,16 @@ | ||
from gtfs_go import GTFSGo | ||
|
||
|
||
def test_run(plugin: GTFSGo): | ||
"""ダイアログを表示する関数のテスト""" | ||
|
||
# 初期状態でダイアログは未初期化 | ||
assert plugin.dialog is None | ||
|
||
plugin.run() | ||
assert plugin.dialog.isVisible() | ||
|
||
plugin.dialog.close() | ||
|
||
assert not plugin.dialog.isVisible() # ダイアログが閉じられても | ||
assert plugin.dialog is not None # インスタンスは保持される |