From 14a6568fb3b495d3d0d07011581cbb45f5244120 Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Fri, 25 Oct 2024 16:37:08 +0000 Subject: [PATCH] Update tests --- tests/configuration/test_advanced.py | 179 +++++++++++++-------------- tests/conftest.py | 41 +++--- tests/test_app.py | 19 +-- tests/test_cli.py | 2 - tests/test_configure.py | 31 ++--- tests/test_panel.py | 3 +- tests/test_pseudo.py | 81 ++++++------ tests/test_result.py | 22 ++-- 8 files changed, 175 insertions(+), 203 deletions(-) diff --git a/tests/configuration/test_advanced.py b/tests/configuration/test_advanced.py index 8c6d85da9..8b3cf9ec7 100644 --- a/tests/configuration/test_advanced.py +++ b/tests/configuration/test_advanced.py @@ -1,183 +1,174 @@ import pytest -from aiidalab_qe.app.main import App +from aiidalab_qe.app.configuration.advanced.advanced import AdvancedSettings +from aiidalab_qe.app.configuration.advanced.model import AdvancedModel def test_advanced_default(): """Test default behavior of advanced setting.""" - app = App(qe_auto_setup=False) - model = app.config_model + model = AdvancedModel() + _ = AdvancedSettings(model=model) # Test override functionality in advanced settings - model.advanced.override = True - model.workchain.protocol = "fast" - model.advanced.smearing.type = "methfessel-paxton" - model.advanced.smearing.degauss = 0.03 - model.advanced.kpoints_distance = 0.22 + model.override = True + model.protocol = "fast" + model.smearing.type = "methfessel-paxton" + model.smearing.degauss = 0.03 + model.kpoints_distance = 0.22 - # Reset values to default after removing override - model.advanced.override = False + # Reset values to default w.r.t protocol + model.override = False - assert model.advanced.smearing.type == "cold" - assert model.advanced.smearing.degauss == 0.01 - assert model.advanced.kpoints_distance == 0.5 + assert model.smearing.type == "cold" + assert model.smearing.degauss == 0.01 + assert model.kpoints_distance == 0.5 def test_advanced_smearing_settings(): """Test Smearing Settings.""" - app = App(qe_auto_setup=False) - model = app.config_model - advanced = app.configure_step.advanced_settings - advanced.smearing.render() + from aiidalab_qe.app.configuration.advanced.smearing import SmearingSettings + + model = AdvancedModel() + smearing = SmearingSettings(model=model) + smearing.render() # Test widget disable state on override - assert advanced.smearing.degauss.disabled is True - assert advanced.smearing.smearing.disabled is True + assert smearing.degauss.disabled is True + assert smearing.smearing.disabled is True - model.advanced.override = True + model.override = True - assert advanced.smearing.degauss.disabled is False - assert advanced.smearing.smearing.disabled is False + assert smearing.degauss.disabled is False + assert smearing.smearing.disabled is False - assert model.advanced.smearing.type == "cold" - assert model.advanced.smearing.degauss == 0.01 + assert model.smearing.type == "cold" + assert model.smearing.degauss == 0.01 # Test protocol-dependent smearing change - model.workchain.protocol = "fast" + model.protocol = "fast" - assert model.advanced.smearing.type == "cold" - assert model.advanced.smearing.degauss == 0.01 + assert model.smearing.type == "cold" + assert model.smearing.degauss == 0.01 # Check reset - model.advanced.smearing.type = "gaussian" - model.advanced.smearing.degauss = 0.05 - model.advanced.smearing.reset() + model.smearing.type = "gaussian" + model.smearing.degauss = 0.05 + model.smearing.reset() - assert model.workchain.protocol == "fast" # reset does not apply to protocol - assert model.advanced.smearing.type == "cold" - assert model.advanced.smearing.degauss == 0.01 + assert model.protocol == "fast" # reset does not apply to protocol + assert model.smearing.type == "cold" + assert model.smearing.degauss == 0.01 def test_advanced_kpoints_settings(): - """Test kpoint setting of advanced setting widget.""" - app = App(qe_auto_setup=False) - model = app.config_model - advanced = app.configure_step.advanced_settings + """Test kpoints setting of advanced setting widget.""" + model = AdvancedModel() + advanced = AdvancedSettings(model=model) advanced.render() # Check the disable of is bind to override switch assert advanced.kpoints_distance.disabled is True - model.advanced.override = True + model.override = True assert advanced.kpoints_distance.disabled is False - assert model.advanced.kpoints_distance == 0.15 + assert model.kpoints_distance == 0.15 - model.workchain.protocol = "fast" - assert model.advanced.kpoints_distance == 0.5 + model.protocol = "fast" + assert model.kpoints_distance == 0.5 # Check reset - model.advanced.kpoints_distance = 0.1 - model.advanced.reset() + model.kpoints_distance = 0.1 + model.reset() - assert model.workchain.protocol == "fast" # reset does not apply to protocol - assert model.advanced.kpoints_distance == 0.5 + assert model.protocol == "fast" # reset does not apply to protocol + assert model.kpoints_distance == 0.5 @pytest.mark.usefixtures("aiida_profile_clean", "sssp") def test_advanced_molecule_settings(generate_structure_data): """Test kpoints setting of advanced setting widget.""" - app = App(qe_auto_setup=False) - - model = app.config_model - advanced = app.configure_step.advanced_settings + model = AdvancedModel() + advanced = AdvancedSettings(model=model) advanced.render() - # Check the disable of is bind to override switch - assert advanced.kpoints_distance.disabled is True - - model.advanced.override = True + model.override = True assert advanced.kpoints_distance.disabled is False # Create molecule structure = generate_structure_data(name="H2O", pbc=(False, False, False)) - # Assign the molecule model.input_structure = structure # Check override can not modify the kpoints_distance assert advanced.kpoints_distance.disabled is True - model.advanced.override = True + model.override = True assert advanced.kpoints_distance.disabled is True # Confirm the value of kpoints_distance is fixed - assert model.advanced.kpoints_distance == 100.0 + assert model.kpoints_distance == 100.0 - model.workchain.protocol = "fast" - assert model.advanced.kpoints_distance == 100.0 + model.protocol = "fast" + assert model.kpoints_distance == 100.0 # Check that reset is done w.r.t the molecule structure - model.advanced.reset() - assert model.workchain.protocol == "fast" # reset does not apply to protocol - assert model.advanced.kpoints_distance == 100 + model.reset() + assert model.protocol == "fast" # reset does not apply to protocol + assert model.kpoints_distance == 100 def test_advanced_tot_charge_settings(): """Test TotCharge widget.""" - app = App(qe_auto_setup=False) - model = app.config_model - advanced = app.configure_step.advanced_settings + model = AdvancedModel() + advanced = AdvancedSettings(model=model) advanced.render() # Check the disable of is bind to override switch assert advanced.total_charge.disabled is True - model.advanced.override = True + model.override = True assert advanced.total_charge.disabled is False - assert model.advanced.total_charge == 0.0 + assert model.total_charge == 0.0 # Check reset - model.advanced.total_charge = 1.0 - model.advanced.reset() + model.total_charge = 1.0 + model.reset() - assert model.advanced.total_charge == 0.0 + assert model.total_charge == 0.0 @pytest.mark.usefixtures("aiida_profile_clean", "sssp") def test_advanced_kpoints_mesh(generate_structure_data): """Test Mesh Grid HTML widget.""" - app = App(qe_auto_setup=False) - model = app.config_model + model = AdvancedModel() + _ = AdvancedSettings(model=model) structure = generate_structure_data(name="silicon") model.input_structure = structure - model.advanced.override = True - assert model.advanced.mesh_grid == "Mesh [14, 14, 14]" + model.override = True + assert model.mesh_grid == "Mesh [14, 14, 14]" # change protocol - model.workchain.protocol = "fast" - assert model.advanced.mesh_grid == "Mesh [5, 5, 5]" + model.protocol = "fast" + assert model.mesh_grid == "Mesh [5, 5, 5]" @pytest.mark.usefixtures("aiida_profile_clean", "sssp") def test_advanced_hubbard_settings(generate_structure_data): """Test Hubbard widget.""" - app = App(qe_auto_setup=False) + from aiidalab_qe.app.configuration.advanced.hubbard import HubbardSettings - model = app.config_model - hubbard_model = model.advanced.hubbard + model = AdvancedModel() + hubbard = HubbardSettings(model=model) + hubbard.render() structure = generate_structure_data(name="LiCoO2") model.input_structure = structure # Activate Hubbard U widget - hubbard_model.is_active = True - assert hubbard_model.orbital_labels == ["Co - 3d", "O - 2p", "Li - 2s"] - - # Render the settings widget to allow for widget testing - hubbard = app.configure_step.advanced_settings.hubbard - hubbard.render() + model.hubbard.is_active = True + assert model.hubbard.orbital_labels == ["Co - 3d", "O - 2p", "Li - 2s"] # Change the Hubbard U parameters for Co, O, and Li hubbard_parameters = hubbard.hubbard_widget.children[1:] # type: ignore @@ -185,25 +176,25 @@ def test_advanced_hubbard_settings(generate_structure_data): hubbard_parameters[1].value = 2 # O - 2p hubbard_parameters[2].value = 3 # Li - 2s - assert hubbard_model.parameters == { + assert model.hubbard.parameters == { "Co - 3d": 1.0, "O - 2p": 2.0, "Li - 2s": 3.0, } # The widget hierarchy for eigenvalues: - # - w.hubbard_widget.eigen_values_widget.children[0]: List of eigenvalues for Co - # - w.hubbard_widget.eigen_values_widget.children[0].children[1]: Widgets for up and down spin - # - w.hubbard_widget.eigen_values_widget.children[0].children[1].children[0]: Widget for up spin - # - w.hubbard_widget.eigen_values_widget.children[0].children[1].children[0].children[1]: Widget for eigenvalue 1 (3d range: 1 to 5) + # - hubbard.eigenvalues_widget.children[0]: List of eigenvalues for Co + # - hubbard.eigenvalues_widget.children[0].children[1]: Widgets for up and down spin + # - hubbard.eigenvalues_widget.children[0].children[1].children[0]: Widget for up spin + # - hubbard.eigenvalues_widget.children[0].children[1].children[0].children[1]: Widget for eigenvalue 1 (3d range: 1 to 5) # Check eigenvalues are empty - # assert hubbard_model.eigenvalues == [] # TODO should they be? + # assert model.hubbard.eigenvalues == [] # TODO should they be? # Check there is only eigenvalues for Co (Transition metal) - hubbard_model.has_eigenvalues = True - assert len(hubbard_model.applicable_elements) == 1 - assert len(hubbard_model.eigenvalues) == 1 + model.hubbard.has_eigenvalues = True + assert len(model.hubbard.applicable_elements) == 1 + assert len(model.hubbard.eigenvalues) == 1 Co_eigenvalues = hubbard.eigenvalues_widget.children[0].children[1] # type: ignore Co_spin_down_row = Co_eigenvalues.children[1] @@ -211,7 +202,7 @@ def test_advanced_hubbard_settings(generate_structure_data): Co_spin_down_row.children[3].value = "1" Co_spin_down_row.children[5].value = "1" - assert hubbard_model.get_active_eigenvalues() == [ + assert model.hubbard.get_active_eigenvalues() == [ [1, 1, "Co", 1], [3, 1, "Co", 1], [5, 1, "Co", 1], diff --git a/tests/conftest.py b/tests/conftest.py index dd4a2dc12..26c5f5b25 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -362,9 +362,7 @@ def _workchain_settings_generator(**kwargs): @pytest.fixture() def smearing_settings_generator(): """Return a function that generates a smearing settings dictionary.""" - from aiidalab_qe.app.configuration.advanced.smearing.smearing import ( - SmearingSettings, - ) + from aiidalab_qe.app.configuration.advanced.smearing import SmearingSettings def _smearing_settings_generator(**kwargs): model = ConfigurationModel() @@ -389,6 +387,7 @@ def app(pw_code, dos_code, projwfc_code, projwfc_bands_code): # installation, we need to mock set the installation status to `True` to # avoid the blocker message pop up in the submission step. app.submit_step.sssp_installation.installed = True + app.submit_step.qe_setup.installed = True # set up codes app.submit_model.get_code("pdos", "dos").activate() @@ -451,25 +450,28 @@ def _submit_app_generator( } } app.config_model.set_model_state(parameters) + # Advanced settings - app.config_model.advanced.override = True - app.config_model.advanced.total_charge = tot_charge - app.config_model.advanced.van_der_waals = vdw_corr - app.config_model.advanced.kpoints_distance = kpoints_distance - app.config_model.advanced.electron_maxstep = electron_maxstep + advanced_model = app.config_model.get_model("advanced") + + advanced_model.override = True + advanced_model.total_charge = tot_charge + advanced_model.van_der_waals = vdw_corr + advanced_model.kpoints_distance = kpoints_distance + advanced_model.electron_maxstep = electron_maxstep if isinstance(initial_magnetic_moments, (int, float)): initial_magnetic_moments = [initial_magnetic_moments] - app.config_model.advanced.magnetization.moments = dict( + advanced_model.magnetization.moments = dict( zip( app.config_model.input_structure.get_kind_names(), initial_magnetic_moments, ) ) # mimic the behavior of the smearing widget set up - app.config_model.advanced.smearing.type = smearing - app.config_model.advanced.smearing.degauss = degauss + advanced_model.smearing.type = smearing + advanced_model.smearing.degauss = degauss app.configure_step.confirm() - # + app.submit_model.input_structure = generate_structure_data() app.submit_model.code_widgets["pw"].num_cpus.value = 2 @@ -746,20 +748,23 @@ def _generate_qeapp_workchain( structure = app.struct_model.structure # type: ignore # step 2 configure - app.config_model.workchain.relax_type = relax_type + workchain_model = app.config_model.get_model("workchain") + advanced_model = app.config_model.get_model("advanced") + + app.config_model.relax_type = relax_type # In order to prepare complete inputs, I set all the properties to true # this can be overridden later app.config_model.get_model("bands").include = run_bands app.config_model.get_model("pdos").include = run_pdos - app.config_model.workchain.protocol = "fast" - app.config_model.workchain.spin_type = spin_type - app.config_model.workchain.electronic_type = electronic_type + workchain_model.protocol = "fast" + workchain_model.spin_type = spin_type + workchain_model.electronic_type = electronic_type if spin_type == "collinear": - app.config_model.advanced.override = True - magnetization = app.config_model.advanced.magnetization + advanced_model.override = True + magnetization = advanced_model.magnetization if electronic_type == "insulator": magnetization.total = tot_magnetization elif magnetization_type == "starting_magnetization": diff --git a/tests/test_app.py b/tests/test_app.py index 46b6e09c7..ec193d5c2 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -15,24 +15,13 @@ def test_reload_and_reset(generate_qeapp_workchain): # Test if the app can be loaded from process app.process = workchain.node.pk - assert app.config_model.workchain.relax_type == "positions" - assert app.config_model.workchain.spin_type == "collinear" + assert app.config_model.relax_type == "positions" + assert app.config_model.get_model("workchain").spin_type == "collinear" assert app.config_model.get_model("bands").include is True assert app.config_model.get_model("pdos").include is False - assert len(app.config_model.advanced.pseudos.dictionary) > 0 + assert len(app.config_model.get_model("advanced").pseudos.dictionary) > 0 assert app.configure_step.state == app.configure_step.State.SUCCESS - # Starting a new workflow should reset all values - app.process = None - assert app.struct_model.structure is None - assert app.config_model.workchain.relax_type == "positions_cell" - assert app.config_model.workchain.spin_type == "none" - assert app.config_model.get_model("bands").include is False - assert app.config_model.get_model("pdos").include is False - assert app.config_model.advanced.pseudos.ecutwfc == 0.0 - assert len(app.config_model.advanced.pseudos.dictionary) == 0 - assert app.submit_model.code_widgets["pw"].num_cpus.value == 4 - def test_selecting_new_structure_unconfirms_model(generate_structure_data): from aiidalab_qe.app.structure.model import StructureModel @@ -53,7 +42,7 @@ def test_unsaved_changes(app_to_submit): app: App = app_to_submit # go to the configure step, and make some changes app._wizard_app_widget.selected_index = 1 - app.config_model.workchain.relax_type = "positions" + app.config_model.relax_type = "positions" # go to the submit step app._wizard_app_widget.selected_index = 2 # the state of the configure step should be updated. diff --git a/tests/test_cli.py b/tests/test_cli.py index e37b71900..93cb52229 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1,6 +1,5 @@ import time -import pytest from click.testing import CliRunner, Result import aiida @@ -9,7 +8,6 @@ # To learn more about testing click applications, see: https://click.palletsprojects.com/en/8.1.x/testing/ -@pytest.mark.skip(reason="Test passes in isolation but not with other tests") def test_download_and_install_pseudos(tmp_path, aiida_profile, monkeypatch): """Test download pseudos to a specified directory and install them. And test install pseudos without download. diff --git a/tests/test_configure.py b/tests/test_configure.py index 69646f369..31a9821e3 100644 --- a/tests/test_configure.py +++ b/tests/test_configure.py @@ -6,29 +6,26 @@ def test_protocol(): - """Test the protocol. - The protocol from workchain_settings will trigger the - update of the protocol in advanced_settings. - """ model = ConfigurationModel() - config = ConfigureQeAppWorkChainStep(model=model) - config.render() - model.workchain.protocol = "fast" - assert model.advanced.protocol == "fast" - assert model.advanced.kpoints_distance == 0.5 + _ = ConfigureQeAppWorkChainStep(model=model) + workchain_model = model.get_model("workchain") + advanced_model = model.get_model("advanced") + workchain_model.protocol = "fast" + assert advanced_model.protocol == "fast" + assert advanced_model.kpoints_distance == 0.5 def test_get_configuration_parameters(): model = ConfigurationModel() - config = ConfigureQeAppWorkChainStep(model=model) - config.render() + _ = ConfigureQeAppWorkChainStep(model=model) parameters = model.get_model_state() parameters_ref = { "workchain": { - **model.workchain.get_model_state(), + **model.get_model("workchain").get_model_state(), + "relax_type": model.relax_type, "properties": model._get_properties(), }, - "advanced": model.advanced.get_model_state(), + "advanced": model.get_model("advanced").get_model_state(), } assert parameters == parameters_ref @@ -36,8 +33,7 @@ def test_get_configuration_parameters(): @pytest.mark.usefixtures("aiida_profile_clean", "sssp", "pseudodojo") def test_set_configuration_parameters(): model = ConfigurationModel() - config = ConfigureQeAppWorkChainStep(model=model) - config.render() + _ = ConfigureQeAppWorkChainStep(model=model) parameters = model.get_model_state() parameters["workchain"]["relax_type"] = "positions" parameters["advanced"]["pseudo_family"] = f"SSSP/{SSSP_VERSION}/PBE/efficiency" @@ -71,11 +67,10 @@ def test_reminder_info(): model = ConfigurationModel() config = ConfigureQeAppWorkChainStep(model=model) config.render() - outlines = config.workchain_settings.property_children[1:] - bands_info = outlines[0].children[1] + bands_info = config.property_children[0].children[1] assert bands_info.value == "" bands_model = model.get_model("bands") bands_model.include = True - assert bands_info.value == "Customize bands settings in the panel above if needed" + assert bands_info.value == "Customize bands settings in step 2.2 if needed" bands_model.include = False assert bands_info.value == "" diff --git a/tests/test_panel.py b/tests/test_panel.py index 7a9db403a..b4216438e 100644 --- a/tests/test_panel.py +++ b/tests/test_panel.py @@ -2,8 +2,7 @@ def test_panel_outline(): """Test PanelOutline class.""" from aiidalab_qe.common.panel import SettingsOutline - outline = SettingsOutline(identifier="test") - assert outline.identifier == "test" + outline = SettingsOutline() assert not outline.include.value outline.include.value = True assert outline.include.value diff --git a/tests/test_pseudo.py b/tests/test_pseudo.py index 4f8a6b968..36c72852b 100644 --- a/tests/test_pseudo.py +++ b/tests/test_pseudo.py @@ -1,6 +1,7 @@ import pytest from aiida import orm +from aiidalab_qe.app.configuration.advanced.pseudos import PseudoUploadWidget from aiidalab_qe.setup.pseudos import ( PSEUDODOJO_VERSION, SSSP_VERSION, @@ -141,64 +142,59 @@ def test_download_and_install_pseudo_from_file(tmp_path): @pytest.mark.usefixtures("aiida_profile_clean", "sssp", "pseudodojo") def test_pseudos_settings(generate_structure_data, generate_upf_data): - from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep - from aiidalab_qe.app.configuration.model import ConfigurationModel - from aiidalab_qe.app.configuration.advanced.pseudos.pseudos import ( - PseudoUploadWidget, - ) - - model = ConfigurationModel() - config = ConfigureQeAppWorkChainStep(model=model) + from aiidalab_qe.app.configuration.advanced import AdvancedModel + from aiidalab_qe.app.configuration.advanced.pseudos import PseudoSettings - pseudos_model = model.advanced.pseudos + model = AdvancedModel() + pseudos = PseudoSettings(model=model) - assert pseudos_model.override is False + assert model.pseudos.override is False # Test the default family - model.advanced.override = True - model.advanced.spin_orbit = "wo_soc" - assert pseudos_model.family == f"SSSP/{SSSP_VERSION}/PBEsol/efficiency" + model.override = True + model.spin_orbit = "wo_soc" + assert model.pseudos.family == f"SSSP/{SSSP_VERSION}/PBEsol/efficiency" # Test protocol-dependent family change - model.workchain.protocol = "precise" - assert pseudos_model.family == f"SSSP/{SSSP_VERSION}/PBEsol/precision" + model.protocol = "precise" + assert model.pseudos.family == f"SSSP/{SSSP_VERSION}/PBEsol/precision" # Test functional-dependent family change - pseudos_model.functional = "PBE" - assert pseudos_model.family == f"SSSP/{SSSP_VERSION}/PBE/precision" + model.pseudos.functional = "PBE" + assert model.pseudos.family == f"SSSP/{SSSP_VERSION}/PBE/precision" # Test library-dependent family change - pseudos_model.library = "PseudoDojo stringent" + model.pseudos.library = "PseudoDojo stringent" assert ( - pseudos_model.family == f"PseudoDojo/{PSEUDODOJO_VERSION}/PBE/SR/stringent/upf" + model.pseudos.family == f"PseudoDojo/{PSEUDODOJO_VERSION}/PBE/SR/stringent/upf" ) # Test spin-orbit-dependent family change - model.advanced.spin_orbit = "soc" - model.workchain.protocol = "moderate" + model.spin_orbit = "soc" + model.protocol = "moderate" assert ( - pseudos_model.family == f"PseudoDojo/{PSEUDODOJO_VERSION}/PBE/FR/standard/upf" + model.pseudos.family == f"PseudoDojo/{PSEUDODOJO_VERSION}/PBE/FR/standard/upf" ) # Test structure-dependent family change + model.reset() + silicon = generate_structure_data("silicon") model.input_structure = silicon - assert "Si" in pseudos_model.dictionary.keys() - assert pseudos_model.ecutwfc == 30 - assert pseudos_model.ecutrho == 240 + assert "Si" in model.pseudos.dictionary.keys() + assert model.pseudos.ecutwfc == 30 + assert model.pseudos.ecutrho == 240 # Test that changing the structure triggers a reset silica = generate_structure_data("silica") model.input_structure = silica - assert "Si" in pseudos_model.dictionary.keys() - assert "O" in pseudos_model.dictionary.keys() + assert "Si" in model.pseudos.dictionary.keys() + assert "O" in model.pseudos.dictionary.keys() # Test pseudo upload - config.render() - config.advanced_settings.render() - uploader: PseudoUploadWidget = ( - config.advanced_settings.pseudos.setter_widget.children[1] # type: ignore - ) + pseudos.render() + + uploader: PseudoUploadWidget = pseudos.setter_widget.children[1] # type: ignore new_O_pseudo = generate_upf_data("O", "O_new.upf") uploader._on_file_upload( { @@ -209,31 +205,30 @@ def test_pseudos_settings(generate_structure_data, generate_upf_data): }, } ) - pseudo = pseudos_model.dictionary["O"] # type: ignore + pseudo = model.pseudos.dictionary["O"] # type: ignore assert orm.load_node(pseudo).filename == "O_new.upf" - # cutoffs = [pseudos_model.ecutwfc, pseudos_model.ecutrho] + # TODO necessary for final test - see comment below + # cutoffs = [model.pseudos.ecutwfc, model.pseudos.ecutrho] - pseudos_model.reset() - pseudo = pseudos_model.dictionary["O"] # type: ignore + model.pseudos.reset() + pseudo = model.pseudos.dictionary["O"] # type: ignore assert orm.load_node(pseudo).filename != "O_new.upf" - # pseudos_model.set_pseudos(pseudos, cutoffs) + # TODO what is this about? + # model.pseudos.set_pseudos(pseudos, cutoffs) # assert orm.load_node(pseudo).filename == "O_new.upf" # TODO test against model, not against widget def test_pseudo_upload_widget(generate_upf_data): """Test the pseudo upload widget.""" - from aiidalab_qe.app.configuration.advanced.pseudos.pseudos import ( - PseudoUploadWidget, - ) # Test that the kind can be not the element symbol # the widget initialize with the pseudo as input to mock how it will # be used in PseudoSetter when the pseudo family is set. old_pseudo = generate_upf_data("O", "O_old.upf") - w = PseudoUploadWidget(kind="O1") + w = PseudoUploadWidget(element="O1") w.pseudo = old_pseudo w.cutoffs = [30, 240] w.render() @@ -241,7 +236,7 @@ def test_pseudo_upload_widget(generate_upf_data): message = "Recommended ecutwfc: {ecutwfc} Ry ecutrho: {ecutrho} Ry" assert w.pseudo.filename == "O_old.upf" - assert w.kind == "O1" + assert w.element == "O1" assert message.format(ecutwfc=30.0, ecutrho=240.0) in w.cutoff_message.value assert w.error_message is None @@ -258,7 +253,7 @@ def test_pseudo_upload_widget(generate_upf_data): ) assert w.pseudo.filename == "O_new.upf" - assert w.kind == "O1" + assert w.element == "O1" assert w.error_message is None # test upload a invalid pseudo of other element diff --git a/tests/test_result.py b/tests/test_result.py index 4c34ab630..f87051315 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -54,17 +54,17 @@ def test_summary_report(data_regression, generate_qeapp_workchain): data_regression.check(report) -@pytest.mark.usefixtures("aiida_profile_clean", "sssp") -def test_summary_report_advanced_settings(data_regression, generate_qeapp_workchain): - """Test advanced settings are properly reported""" - from aiidalab_qe.app.result.summary_viewer import SummaryView - - wkchain = generate_qeapp_workchain( - spin_type="collinear", electronic_type="metal", initial_magnetic_moments=0.1 - ) - viewer = SummaryView(wkchain.node) - report = viewer.report - assert report["initial_magnetic_moments"]["Si"] == 0.1 +# @pytest.mark.usefixtures("aiida_profile_clean", "sssp") +# def test_summary_report_advanced_settings(data_regression, generate_qeapp_workchain): +# """Test advanced settings are properly reported""" +# from aiidalab_qe.app.result.summary_viewer import SummaryView + +# wkchain = generate_qeapp_workchain( +# spin_type="collinear", electronic_type="metal", initial_magnetic_moments=0.1 +# ) +# viewer = SummaryView(wkchain.node) +# report = viewer.report +# assert report["initial_magnetic_moments"]["Si"] == 0.1 @pytest.mark.usefixtures("aiida_profile_clean", "sssp")