Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Dec 3, 2024
1 parent a9ce355 commit 63adb5b
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions napari_plugin_manager/_tests/test_qt_plugin_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from napari.utils.translations import trans
from qtpy.QtCore import QMimeData, QPointF, Qt, QUrl
from qtpy.QtGui import QDropEvent
from qtpy.QtWidgets import QMessageBox

if qtpy.API_NAME == 'PySide2' and sys.version_info[:2] > (3, 10):
pytest.skip(
Expand Down Expand Up @@ -484,6 +485,35 @@ def test_installs(qtbot, tmp_virtualenv, plugin_dialog, request):
qtbot.wait(5000)


@pytest.mark.parametrize(
"message_return",
[QMessageBox.StandardButton.Cancel, QMessageBox.StandardButton.Ok],
)
def test_install_pypi_constructor(
qtbot, tmp_virtualenv, plugin_dialog, request, message_return
):
if "no-constructor" in request.node.name:
pytest.skip(
reason="This test is only relevant for constructor-based installs"
)

plugin_dialog.set_prefix(str(tmp_virtualenv))
plugin_dialog.search('requests')
qtbot.wait(500)
item = plugin_dialog.available_list.item(0)
widget = plugin_dialog.available_list.itemWidget(item)
with patch.object(qt_plugin_dialog.QMessageBox, "exec_") as mock:
mock.return_value = message_return
if message_return == QMessageBox.StandardButton.Ok:
with qtbot.waitSignal(
plugin_dialog.installer.processFinished, timeout=60_000
):
widget.action_button.click()
else:
widget.action_button.click()
assert mock.called


def test_cancel(qtbot, tmp_virtualenv, plugin_dialog, request):
if "[constructor]" in request.node.name:
pytest.skip(
Expand Down

0 comments on commit 63adb5b

Please sign in to comment.