Skip to content

Commit 4e650d6

Browse files
author
Axel Hörteborn
committed
Added another test and some more docstrings
1 parent 773c290 commit 4e650d6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

a00_qpip/plugin.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@
2121
class Plugin:
2222
"""QGIS Plugin Implementation."""
2323

24-
def __init__(self, iface, test_path=None):
24+
def __init__(self, iface, plugin_path=None):
2525
self.iface = iface
2626
self._defered_packages = []
2727
self.settings = QgsSettings()
2828
self.settings.beginGroup("QPIP")
2929

30-
if test_path is None:
30+
if plugin_path is None:
3131
self.plugins_path = os.path.join(
3232
QgsApplication.qgisSettingsDirPath(), "python", "plugins"
3333
)
3434
else:
35-
self.plugins_path = test_path
35+
self.plugins_path = plugin_path
3636
self.prefix_path = os.path.join(
3737
QgsApplication.qgisSettingsDirPath().replace("/", os.path.sep),
3838
"python",
@@ -136,6 +136,10 @@ def check_deps(self, additional_plugins=[]) -> MainDialog | bool:
136136
"""
137137
This checks dependencies for installed plugins and to-be installed plugins. If
138138
anything is missing, shows a GUI to install them.
139+
140+
The function returns:
141+
- MainDialog, the QDialog object (without opening it)
142+
- A bool if the dialog needs to be opened or not
139143
"""
140144

141145
plugin_names = [*qgis.utils.active_plugins, *additional_plugins]

tests/test_finding_req.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ def plugin(qgis_iface):
2626

2727
def test_plugin_a(plugin: Plugin):
2828
plugin_a = os.path.join(THIS_DIR, '..', 'test_plugins', 'plugin_a')
29-
dialog, _ = plugin.check_deps([plugin_a])
29+
dialog, needs_gui = plugin.check_deps([plugin_a])
3030
libs = dialog.reqs_to_install
3131
assert len(libs) == 2
3232
assert libs[0] == 'cowsay==4.0'
33+
assert needs_gui
3334

3435

3536
def test_plugin_b(plugin: Plugin):
3637
plugin_b = os.path.join(THIS_DIR, '..', 'test_plugins', 'plugin_b')
37-
dialog, _ = plugin.check_deps([plugin_b])
38+
dialog, needs_gui = plugin.check_deps([plugin_b])
3839
libs = dialog.reqs_to_install
3940
assert len(libs) == 2
40-
assert libs[0] == 'cowsay==5.0'
41+
assert libs[0] == 'cowsay==5.0'
42+
assert needs_gui

0 commit comments

Comments
 (0)