Skip to content

Commit

Permalink
Test for detailed setup widget
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Sep 6, 2023
1 parent 675ea84 commit 601f75e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aiidalab_widgets_base/computational_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,21 @@ class ComputationalResourcesWidget(ipw.VBox):
default_calc_job_plugin = traitlets.Unicode(allow_none=True)

def __init__(
self, description="Select code:", path_to_root="../", quick_setup=True, **kwargs
self,
description="Select code:",
path_to_root="../",
quick_setup=True,
clear_after=None,
**kwargs,
):
"""Dropdown for Codes for one input plugin.
description (str): Description to display before the dropdown.
"""
clear_after = clear_after or 30
self.enable_quick_setup = quick_setup
self.output = ipw.HTML()
self.setup_message = StatusHTML(clear_after=30)
self.setup_message = StatusHTML(clear_after=clear_after)
self.code_select_dropdown = ipw.Dropdown(
description=description,
disabled=True,
Expand Down
34 changes: 34 additions & 0 deletions tests/test_computational_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ def test_computer_dropdown_widget(aiida_localhost):
assert widget._dropdown.value is None


@pytest.mark.usefixtures("aiida_profile_clean")
def test_quick_setup_widget():
"""Test the QuickSetupWidget."""
from aiidalab_widgets_base.computational_resources import QuickSetupWidget
Expand Down Expand Up @@ -243,3 +244,36 @@ def test_quick_setup_widget():

assert "created" in w.message
assert w.success

# XXX: select new resource should reset the widget, success trait, and message trait.


@pytest.mark.usefixtures("aiida_profile_clean")
def test_bundle_resource_setup_widget():
"""This is the bundle test of the resource setup widget specifically to DetailedSetupWidget.
Since the DetailedSetupWidget is a container widget, it is meaningless to test it independently.
"""
from aiidalab_widgets_base.computational_resources import (
ComputationalResourcesWidget,
)

# Set with clear_after=1 to avoid the widget frozen at the end of test to wait the counting thread to finish.
w = ComputationalResourcesWidget(clear_after=1)

# go last step to setup code withou computer setup
w_quick = w.quick_setup
w_detailed = w.detailed_setup

w_quick.comp_resources_database.inp_domain.value = "daint.cscs.ch"
w_quick.comp_resources_database.inp_computer.value = "multicore"
w_quick.comp_resources_database.inp_code.value = "pw-7.0-multicore"

# Check that the computer/code setup widget is updated accordingly in the detailed setup widget.
# By triggering the setup button one by one in the detailed setup widget, the message should be updated.
w_detailed.aiida_computer_setup.on_setup_computer()

assert "created" in w_detailed.message

w_detailed.aiida_code_setup.on_setup_code()

assert "created" in w_detailed.message

0 comments on commit 601f75e

Please sign in to comment.