Skip to content

Commit

Permalink
Test about window
Browse files Browse the repository at this point in the history
Mocks view and thus does not require a GUI framework to run tests.

Related pwr-Solaar#2395
  • Loading branch information
MattHag committed Apr 10, 2024
1 parent dfc3160 commit 39a61d8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/solaar/ui/about_dialog/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .about import show_window # noqa: F401
4 changes: 2 additions & 2 deletions lib/solaar/ui/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from . import action as _action
from . import config_panel as _config_panel
from . import icons as _icons
from .about_dialog import about
from .about_dialog import show_window as show_about_window
from .common import ui_async as _ui_async
from .diversion_rules import show_window as _show_diversion_window

Expand Down Expand Up @@ -305,7 +305,7 @@ def _create_window_layout():
bottom_buttons_box.set_spacing(20)
quit_button = _new_button(_("Quit %s") % NAME, "application-exit", _SMALL_BUTTON_ICON_SIZE, clicked=destroy)
bottom_buttons_box.add(quit_button)
about_button = _new_button(_("About %s") % NAME, "help-about", _SMALL_BUTTON_ICON_SIZE, clicked=about.show_window)
about_button = _new_button(_("About %s") % NAME, "help-about", _SMALL_BUTTON_ICON_SIZE, clicked=show_about_window)
bottom_buttons_box.add(about_button)
diversion_button = _new_button(
_("Rule Editor"), "", _SMALL_BUTTON_ICON_SIZE, clicked=lambda *_trigger: _show_diversion_window(_model)
Expand Down
29 changes: 29 additions & 0 deletions tests/solaar/ui/test_about_window.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from solaar.ui.about_dialog.model import AboutModel
from solaar.ui.about_dialog.presenter import Presenter


def test_about_model():
expected_name = "Daniel Pavel"
model = AboutModel()

authors = model.get_authors()

assert expected_name in authors[0]


def test_about_dialog(mocker):
model = AboutModel()
view = mocker.Mock()
presenter = Presenter(model, view)

presenter.run()

assert view.init_ui.call_count == 1
assert view.update_version_info.call_count == 1
assert view.update_description.call_count == 1
assert view.update_authors.call_count == 1
assert view.update_credits.call_count == 1
assert view.update_copyright.call_count == 1
assert view.update_translators.call_count == 1
assert view.update_website.call_count == 1
assert view.show.call_count == 1

0 comments on commit 39a61d8

Please sign in to comment.