Skip to content

Commit

Permalink
Initial GUI tests
Browse files Browse the repository at this point in the history
The GUI is rather useless when the app is being run in the test environment, as there are no printers connected (there is no USB backend at all).
This simple test verifies the most basic existence of selected widget, and their content.
We will need to figure out how to test the app with a state that resembles actual printer. We might need to introduce test mode, in which all supported printers are shown in the device selector, so we can test various features for each.
  • Loading branch information
Tomer Shalev authored and maresb committed May 4, 2024
1 parent f442494 commit 9fbf7b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ requires-python = ">=3.8,<4"
[project.optional-dependencies]
test = [
"pytest-cov",
"pytest-image-diff"
"pytest-image-diff",
"pytest-qt",
]

[project.urls]
Expand Down
25 changes: 25 additions & 0 deletions src/labelle/gui/tests/test_gui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from labelle.gui.gui import LabelleWindow
from labelle.gui.q_label_widgets import (
TextDymoLabelWidget,
)


def test_main_window(qtbot):
widget = LabelleWindow()
qtbot.addWidget(widget)

assert not widget._actions.isEnabled()
assert widget._device_selector.isEnabled()
assert not widget._label_list.isEnabled()
assert not widget._render_widget.isEnabled()
assert not widget._render.isEnabled()
assert not widget._settings_toolbar.isEnabled()
assert (
widget._device_selector._error_label.text()
== "Failed scanning devices: No backend available"
)
assert not widget._actions._print_button.isEnabled()
assert widget._label_list.count() == 1
item = widget._label_list.itemWidget(widget._label_list.item(0))
assert isinstance(item, TextDymoLabelWidget)
assert item.label.toPlainText() == "text"

0 comments on commit 9fbf7b0

Please sign in to comment.