From 20ea2d15ab49790b7c29bd87ef50760ee9ec0714 Mon Sep 17 00:00:00 2001 From: Edan Bainglass Date: Thu, 14 Nov 2024 08:48:12 +0000 Subject: [PATCH] Fix all but one test - in progress --- tests/test_plugins_bands.py | 44 +++++++++++----------- tests/test_plugins_electronic_structure.py | 2 - tests/test_plugins_pdos.py | 2 - tests/test_result.py | 5 ++- 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/tests/test_plugins_bands.py b/tests/test_plugins_bands.py index e7e34843..8744d8ac 100644 --- a/tests/test_plugins_bands.py +++ b/tests/test_plugins_bands.py @@ -15,8 +15,6 @@ def test_result(generate_qeapp_workchain): model = widget._model assert isinstance(widget, BandPdosWidget) - - widget.plot_button.click() assert isinstance(widget.plot, go.FigureWidget) # Check if data is correct @@ -31,24 +29,24 @@ def test_result(generate_qeapp_workchain): assert model.bands_data["pathlabels"][0] == list(widget.plot.layout.xaxis.ticktext) # type: ignore -# def test_structure_1d(generate_qeapp_workchain, generate_structure_data): -# structure = generate_structure_data("silicon", pbc=(True, False, False)) -# workchain = generate_qeapp_workchain(structure=structure) -# assert "bands_kpoints_distance" not in workchain.inputs.bands.bands -# assert "bands_kpoints" in workchain.inputs.bands.bands -# assert len(workchain.inputs.bands.bands.bands_kpoints.labels) == 2 -# assert workchain.inputs.bands.bands.bands_kpoints.labels == [(0, "Γ"), (9, "X")] - - -# def test_structure_2d(generate_qeapp_workchain, generate_structure_data): -# structure = generate_structure_data("MoS2", pbc=(True, True, False)) -# workchain = generate_qeapp_workchain(structure=structure) -# assert "bands_kpoints_distance" not in workchain.inputs.bands.bands -# assert "bands_kpoints" in workchain.inputs.bands.bands -# assert len(workchain.inputs.bands.bands.bands_kpoints.labels) == 4 -# assert workchain.inputs.bands.bands.bands_kpoints.labels == [ -# (0, "Γ"), -# (11, "M"), -# (18, "K"), -# (31, "Γ"), -# ] +def test_structure_1d(generate_qeapp_workchain, generate_structure_data): + structure = generate_structure_data("silicon", pbc=(True, False, False)) + workchain = generate_qeapp_workchain(structure=structure) + assert "bands_kpoints_distance" not in workchain.inputs.bands.bands + assert "bands_kpoints" in workchain.inputs.bands.bands + assert len(workchain.inputs.bands.bands.bands_kpoints.labels) == 2 + assert workchain.inputs.bands.bands.bands_kpoints.labels == [(0, "Γ"), (9, "X")] + + +def test_structure_2d(generate_qeapp_workchain, generate_structure_data): + structure = generate_structure_data("MoS2", pbc=(True, True, False)) + workchain = generate_qeapp_workchain(structure=structure) + assert "bands_kpoints_distance" not in workchain.inputs.bands.bands + assert "bands_kpoints" in workchain.inputs.bands.bands + assert len(workchain.inputs.bands.bands.bands_kpoints.labels) == 4 + assert workchain.inputs.bands.bands.bands_kpoints.labels == [ + (0, "Γ"), + (11, "M"), + (18, "K"), + (31, "Γ"), + ] diff --git a/tests/test_plugins_electronic_structure.py b/tests/test_plugins_electronic_structure.py index 0e68e808..b54d0b3b 100644 --- a/tests/test_plugins_electronic_structure.py +++ b/tests/test_plugins_electronic_structure.py @@ -18,8 +18,6 @@ def test_electronic_structure(generate_qeapp_workchain): model = widget._model assert isinstance(widget, BandPdosWidget) - - widget.plot_button.click() assert isinstance(widget.plot, go.FigureWidget) # Check if data is correct diff --git a/tests/test_plugins_pdos.py b/tests/test_plugins_pdos.py index cc1f62e0..af6ef8a1 100644 --- a/tests/test_plugins_pdos.py +++ b/tests/test_plugins_pdos.py @@ -15,8 +15,6 @@ def test_result(generate_qeapp_workchain): model = widget._model assert isinstance(widget, BandPdosWidget) - - widget.plot_button.click() assert isinstance(widget.plot, go.FigureWidget) # Check if data is correct diff --git a/tests/test_result.py b/tests/test_result.py index 52e142ff..85615d80 100644 --- a/tests/test_result.py +++ b/tests/test_result.py @@ -4,7 +4,7 @@ from aiidalab_qe.app.main import App from aiidalab_qe.app.result.summary import WorkChainSummaryModel -from aiidalab_qe.app.result.viewer import WorkChainViewer +from aiidalab_qe.app.result.viewer import WorkChainViewer, WorkChainViewerModel def test_result_step(app_to_submit, generate_qeapp_workchain): @@ -32,7 +32,8 @@ def test_workchainview(generate_qeapp_workchain): workchain = generate_qeapp_workchain() workchain.node.seal() - viewer = WorkChainViewer(workchain.node) + model = WorkChainViewerModel() + viewer = WorkChainViewer(workchain.node, model=model) time.sleep(3) assert len(viewer.tabs.children) == 5 assert viewer.tabs._titles["0"] == "Workflow Summary" # type: ignore