-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
98cbea8
commit 1aeaee9
Showing
3 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from aiidalab_qe.app.infobox import InfoBox | ||
|
||
|
||
def test_infobox_classes(): | ||
"""Test `InfoBox` classes.""" | ||
infobox = InfoBox() | ||
assert "info-box" in infobox._dom_classes | ||
infobox = InfoBox(**{"custom-css": "custom-info-box"}) | ||
assert all( | ||
css_class in infobox._dom_classes | ||
for css_class in ( | ||
"info-box", | ||
"custom-info-box", | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from aiidalab_qe.app.wrapper import AppWrapperContoller, AppWrapperModel, AppWrapperView | ||
|
||
|
||
class TestWrapper: | ||
def test_enable_toggles(self): | ||
"""Test enable_toggles method.""" | ||
self._instansiate_mvc_components() | ||
assert self.view.guide_toggle.disabled is True | ||
assert self.view.about_toggle.disabled is True | ||
self.controller.enable_toggles() | ||
assert self.view.guide_toggle.disabled is False | ||
assert self.view.about_toggle.disabled is False | ||
|
||
def test_guide_toggle(self): | ||
"""Test guide_toggle method.""" | ||
self._instansiate_mvc_components() | ||
self.controller.enable_toggles() | ||
self.controller._on_guide_toggle({"new": True}) | ||
self._assert_guide_is_on() | ||
self.controller._on_guide_toggle({"new": False}) | ||
self._assert_no_guide_info() | ||
|
||
def test_about_toggle(self): | ||
"""Test about_toggle method.""" | ||
self._instansiate_mvc_components() | ||
self.controller.enable_toggles() | ||
self.controller._on_about_toggle({"new": True}) | ||
self._assert_about_is_on() | ||
self.controller._on_about_toggle({"new": False}) | ||
self._assert_no_guide_info() | ||
|
||
def test_toggle_switch(self): | ||
"""Test toggle_switch method.""" | ||
self._instansiate_mvc_components() | ||
self.controller.enable_toggles() | ||
self._assert_no_guide_info() | ||
self.controller._on_guide_toggle({"new": True}) | ||
self._assert_guide_is_on() | ||
self.controller._on_about_toggle({"new": True}) | ||
self._assert_about_is_on() | ||
self.controller._on_guide_toggle({"new": True}) | ||
self._assert_guide_is_on() | ||
self.controller._on_guide_toggle({"new": False}) | ||
self._assert_no_guide_info() | ||
|
||
def _assert_guide_is_on(self): | ||
"""Assert guide is on.""" | ||
assert len(self.view.info_container.children) == 1 | ||
assert self.view.guide in self.view.info_container.children | ||
|
||
def _assert_about_is_on(self): | ||
"""Assert about is on.""" | ||
assert len(self.view.info_container.children) == 1 | ||
assert self.view.about in self.view.info_container.children | ||
|
||
def _assert_no_guide_info(self): | ||
"""Assert no info is shown.""" | ||
assert len(self.view.info_container.children) == 0 | ||
|
||
def _instansiate_mvc_components(self): | ||
"""Instansiate `AppWrapper` MVC components.""" | ||
self.model = AppWrapperModel() | ||
self.view = AppWrapperView() | ||
self.controller = AppWrapperContoller(self.model, self.view) |