Skip to content

Commit 2136e32

Browse files
authored
Merge pull request #88 from MIERUNE/feat/test
Feat/test
2 parents 300615f + a315801 commit 2136e32

10 files changed

+558
-21
lines changed

.github/workflows/release.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ jobs:
1414
with:
1515
submodules: true
1616
fetch-depth: 0
17+
# 内容を書き換えるファイルの名前を一時的に変更
18+
- name: rename some files to rewrite
19+
run: |
20+
cp ./metadata.txt ./metadata.old.txt
21+
# metadata.txtにバージョン情報を書き込み
22+
- name: metadata
23+
run : |
24+
sed -e "s/version={{PLUGIN_VERSION}}/version=${{ github.event.release.tag_name }}/g" ./metadata.old.txt > ./metadata.txt
25+
rm ./metadata.old.txt
1726
- name: Create Plugin Directory
1827
run: |
1928
mkdir ${{env.PLUGIN_NAME}}

convert_fgd_dem

metadata.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
name=QuickDEM4JP
1111
qgisMinimumVersion=3.16
1212
description=Convert DEM XML files, provided by Geospatial Information Authority of Japan(GSI) to DEM GeoTiff and/or Terrain RGB format GeoTiff.
13-
version=1.1.0
13+
version={{PLUGIN_VERSION}}
1414
author=MIERUNE Inc.
1515
1616

poetry.lock

+471
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.toml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[virtualenvs]
2+
in-project = true
3+
4+
[virtualenvs.options]
5+
system-site-packages = true

pyproject.toml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[tool.poetry]
2+
name = "quickdem4jp"
3+
version = "1.1.2"
4+
description = "Convert XML DEM files provided by Geospatial Information Authority of Japan(GSI) to GeoTiff format and/or Terrain RGB format DEM."
5+
authors = ["MIERUNE Inc. <[email protected]>"]
6+
license = "GPL-2.0 license"
7+
readme = "README.md"
8+
packages = [
9+
#{ include = "qgis", from = "C:\\Program Files\\QGIS 3.28.2\\apps\\qgis\\python" },
10+
]
11+
12+
[tool.poetry.dependencies]
13+
python = "^3.8"
14+
15+
[tool.poetry.group.dev.dependencies]
16+
black = "^24.3.0"
17+
flake8 = "^6.0.0"
18+
isort = "^5.12.0"
19+
pytest = "^7.2.1"
20+
flake8-bugbear = "^23.3.12"
21+
pytest-cov = "^4.0.0"
22+
pytest-qgis = "^1.3.2"
23+
24+
25+
[tool.poetry.group.pyqt5.dependencies]
26+
pyqt5 = "^5.15.9"
27+
28+
[build-system]
29+
requires = ["poetry-core"]
30+
build-backend = "poetry.core.masonry.api"

quick_dem_for_jp.py

+17-19
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,26 @@ def __init__(self, iface):
4040
self.iface = iface
4141
# initialize plugin directory
4242
self.plugin_dir = os.path.dirname(__file__)
43-
self.icon_path = os.path.join(self.plugin_dir, 'icon.png')
43+
self.icon_path = os.path.join(self.plugin_dir, "icon.png")
4444
# initialize locale
45-
locale = QSettings().value('locale/userLocale')[0:2]
45+
if QSettings().value("locale/userLocale") is not None:
46+
locale = QSettings().value("locale/userLocale")[0:2]
47+
else:
48+
locale = "en"
4649
locale_path = os.path.join(
47-
self.plugin_dir,
48-
'i18n',
49-
'QuickDEMforJP_{}.qm'.format(locale))
50+
self.plugin_dir, "i18n", "QuickDEMforJP_{}.qm".format(locale)
51+
)
5052

5153
if os.path.exists(locale_path):
5254
self.translator = QTranslator()
5355
self.translator.load(locale_path)
5456

55-
if qVersion() > '4.3.3':
57+
if qVersion() > "4.3.3":
5658
QCoreApplication.installTranslator(self.translator)
5759

5860
# Declare instance attributes
5961
self.actions = []
60-
self.menu = self.tr(u'&Quick_DEM_for_JP')
62+
self.menu = self.tr("&Quick_DEM_for_JP")
6163

6264
# Check if plugin was started the first time in current QGIS session
6365
# Must be set in initGui() to survive plugin reloads
@@ -66,7 +68,7 @@ def __init__(self, iface):
6668
# noinspection PyMethodMayBeStatic
6769
def tr(self, message):
6870
# noinspection PyTypeChecker,PyArgumentList,PyCallByClass
69-
return QCoreApplication.translate('QuickDEMforJP', message)
71+
return QCoreApplication.translate("QuickDEMforJP", message)
7072

7173
def add_action(
7274
self,
@@ -78,7 +80,7 @@ def add_action(
7880
add_to_toolbar=True,
7981
status_tip=None,
8082
whats_this=None,
81-
parent=None
83+
parent=None,
8284
):
8385

8486
icon = QIcon(icon_path)
@@ -97,9 +99,7 @@ def add_action(
9799
self.iface.addToolBarIcon(action)
98100

99101
if add_to_menu:
100-
self.iface.addPluginToMenu(
101-
self.menu,
102-
action)
102+
self.iface.addPluginToMenu(self.menu, action)
103103

104104
self.actions.append(action)
105105

@@ -110,22 +110,20 @@ def initGui(self):
110110

111111
self.add_action(
112112
self.icon_path,
113-
text=self.tr(u'Quick_DEM_for_JP'),
113+
text=self.tr("Quick_DEM_for_JP"),
114114
callback=self.dialog_show,
115-
parent=self.iface.mainWindow())
115+
parent=self.iface.mainWindow(),
116+
)
116117

117118
# will be set False in run()
118119
self.first_start = True
119120

120121
def unload(self):
121122
"""Removes the plugin menu item and icon from QGIS GUI."""
122123
for action in self.actions:
123-
self.iface.removePluginMenu(
124-
self.tr(u'&Quick_DEM_for_JP'),
125-
action)
124+
self.iface.removePluginMenu(self.tr("&Quick_DEM_for_JP"), action)
126125
self.iface.removeToolBarIcon(action)
127126

128127
def dialog_show(self):
129-
self.contents = Contents(
130-
self.iface)
128+
self.contents = Contents(self.iface)
131129
self.contents.dlg.show()

tests/__init__.py

Whitespace-only changes.

tests/conftest.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from typing import Iterable
2+
3+
import pytest
4+
5+
from qgis.gui import QgisInterface
6+
7+
from ..__init__ import classFactory
8+
9+
10+
@pytest.fixture()
11+
def plugin(qgis_iface: QgisInterface) -> Iterable[None]:
12+
_plugin = classFactory(qgis_iface)
13+
_plugin.initGui()
14+
15+
yield _plugin
16+
17+
# _plugin.unload() QgisInterface.removePluginMenu()がpytest-qgisで未実装

tests/test_dialog.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from ..quick_dem_for_jp import QuickDEMforJP
2+
from ..contents import Contents
3+
4+
5+
def test_show_dialog(plugin: QuickDEMforJP):
6+
plugin.dialog_show()
7+
assert isinstance(plugin.contents, Contents)

0 commit comments

Comments
 (0)