Skip to content

Commit

Permalink
Merge pull request #88 from MIERUNE/feat/test
Browse files Browse the repository at this point in the history
Feat/test
  • Loading branch information
nbayashi authored Aug 29, 2024
2 parents 300615f + a315801 commit 2136e32
Show file tree
Hide file tree
Showing 10 changed files with 558 additions and 21 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ jobs:
with:
submodules: true
fetch-depth: 0
# 内容を書き換えるファイルの名前を一時的に変更
- name: rename some files to rewrite
run: |
cp ./metadata.txt ./metadata.old.txt
# metadata.txtにバージョン情報を書き込み
- name: metadata
run : |
sed -e "s/version={{PLUGIN_VERSION}}/version=${{ github.event.release.tag_name }}/g" ./metadata.old.txt > ./metadata.txt
rm ./metadata.old.txt
- name: Create Plugin Directory
run: |
mkdir ${{env.PLUGIN_NAME}}
Expand Down
2 changes: 1 addition & 1 deletion convert_fgd_dem
Submodule convert_fgd_dem updated 0 files
2 changes: 1 addition & 1 deletion metadata.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name=QuickDEM4JP
qgisMinimumVersion=3.16
description=Convert DEM XML files, provided by Geospatial Information Authority of Japan(GSI) to DEM GeoTiff and/or Terrain RGB format GeoTiff.
version=1.1.0
version={{PLUGIN_VERSION}}
author=MIERUNE Inc.
email=info@mierune.co.jp

Expand Down
471 changes: 471 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[virtualenvs]
in-project = true

[virtualenvs.options]
system-site-packages = true
30 changes: 30 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[tool.poetry]
name = "quickdem4jp"
version = "1.1.2"
description = "Convert XML DEM files provided by Geospatial Information Authority of Japan(GSI) to GeoTiff format and/or Terrain RGB format DEM."
authors = ["MIERUNE Inc. <info@mierune.co.jp>"]
license = "GPL-2.0 license"
readme = "README.md"
packages = [
#{ include = "qgis", from = "C:\\Program Files\\QGIS 3.28.2\\apps\\qgis\\python" },
]

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.group.dev.dependencies]
black = "^24.3.0"
flake8 = "^6.0.0"
isort = "^5.12.0"
pytest = "^7.2.1"
flake8-bugbear = "^23.3.12"
pytest-cov = "^4.0.0"
pytest-qgis = "^1.3.2"


[tool.poetry.group.pyqt5.dependencies]
pyqt5 = "^5.15.9"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
36 changes: 17 additions & 19 deletions quick_dem_for_jp.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,26 @@ def __init__(self, iface):
self.iface = iface
# initialize plugin directory
self.plugin_dir = os.path.dirname(__file__)
self.icon_path = os.path.join(self.plugin_dir, 'icon.png')
self.icon_path = os.path.join(self.plugin_dir, "icon.png")
# initialize locale
locale = QSettings().value('locale/userLocale')[0:2]
if QSettings().value("locale/userLocale") is not None:
locale = QSettings().value("locale/userLocale")[0:2]
else:
locale = "en"
locale_path = os.path.join(
self.plugin_dir,
'i18n',
'QuickDEMforJP_{}.qm'.format(locale))
self.plugin_dir, "i18n", "QuickDEMforJP_{}.qm".format(locale)
)

if os.path.exists(locale_path):
self.translator = QTranslator()
self.translator.load(locale_path)

if qVersion() > '4.3.3':
if qVersion() > "4.3.3":
QCoreApplication.installTranslator(self.translator)

# Declare instance attributes
self.actions = []
self.menu = self.tr(u'&Quick_DEM_for_JP')
self.menu = self.tr("&Quick_DEM_for_JP")

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

def add_action(
self,
Expand All @@ -78,7 +80,7 @@ def add_action(
add_to_toolbar=True,
status_tip=None,
whats_this=None,
parent=None
parent=None,
):

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

if add_to_menu:
self.iface.addPluginToMenu(
self.menu,
action)
self.iface.addPluginToMenu(self.menu, action)

self.actions.append(action)

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

self.add_action(
self.icon_path,
text=self.tr(u'Quick_DEM_for_JP'),
text=self.tr("Quick_DEM_for_JP"),
callback=self.dialog_show,
parent=self.iface.mainWindow())
parent=self.iface.mainWindow(),
)

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

def unload(self):
"""Removes the plugin menu item and icon from QGIS GUI."""
for action in self.actions:
self.iface.removePluginMenu(
self.tr(u'&Quick_DEM_for_JP'),
action)
self.iface.removePluginMenu(self.tr("&Quick_DEM_for_JP"), action)
self.iface.removeToolBarIcon(action)

def dialog_show(self):
self.contents = Contents(
self.iface)
self.contents = Contents(self.iface)
self.contents.dlg.show()
Empty file added tests/__init__.py
Empty file.
17 changes: 17 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from typing import Iterable

import pytest

from qgis.gui import QgisInterface

from ..__init__ import classFactory


@pytest.fixture()
def plugin(qgis_iface: QgisInterface) -> Iterable[None]:
_plugin = classFactory(qgis_iface)
_plugin.initGui()

yield _plugin

# _plugin.unload() QgisInterface.removePluginMenu()がpytest-qgisで未実装
7 changes: 7 additions & 0 deletions tests/test_dialog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from ..quick_dem_for_jp import QuickDEMforJP
from ..contents import Contents


def test_show_dialog(plugin: QuickDEMforJP):
plugin.dialog_show()
assert isinstance(plugin.contents, Contents)

0 comments on commit 2136e32

Please sign in to comment.