Skip to content

Commit 04a688e

Browse files
author
lukaspie
committed
add tests for the NeXus app
1 parent 2999262 commit 04a688e

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

tests/nomad/test_nexus_app.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#
2+
# Copyright The NOMAD Authors.
3+
#
4+
# This file is part of NOMAD. See https://nomad-lab.eu for further info.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
"""Test for the NeXus app."""
19+
20+
import pytest
21+
22+
try:
23+
import nomad # noqa: F401
24+
except ImportError:
25+
pytest.skip(
26+
"Skipping NOMAD app tests because nomad-lab is not installed",
27+
allow_module_level=True,
28+
)
29+
30+
from pynxtools.nomad.apps import nexus_app
31+
32+
33+
def test_nexus_app_basic_properties():
34+
"""Verify basic metadata of the NeXus app."""
35+
app = nexus_app.app
36+
37+
assert app.label == "NeXus"
38+
assert app.path == "nexusapp"
39+
assert app.category == "Experiment"
40+
41+
42+
def test_nexus_app_locked_filters():
43+
"""Ensure required locked filters are defined and well-formed."""
44+
app = nexus_app.app
45+
46+
assert "section_defs.definition_qualified_name" in app.filters_locked
47+
assert isinstance(
48+
app.filters_locked["section_defs.definition_qualified_name"], list
49+
)
50+
assert len(app.filters_locked["section_defs.definition_qualified_name"]) == 1
51+
52+
53+
def test_nexus_app_columns():
54+
"""Check that a representative result column is configured correctly."""
55+
app = nexus_app.app
56+
57+
definition_column = next(col for col in app.columns if col.title == "Definition")
58+
59+
assert definition_column.selected is True
60+
assert "data.ENTRY" in definition_column.search_quantity
61+
62+
63+
def test_nexus_app_menu_contains_elements_section():
64+
"""Validate presence and structure of the Elements menu section."""
65+
app = nexus_app.app
66+
67+
elements_menu = next(item for item in app.menu.items if item.title == "Elements")
68+
69+
assert elements_menu.size.name == "XXL"
70+
assert any(
71+
item.__class__.__name__ == "MenuItemPeriodicTable"
72+
for item in elements_menu.items
73+
)
74+
75+
76+
def test_nexus_app_dashboard_widgets():
77+
"""Ensure the dashboard contains a valid periodic table widget."""
78+
dashboard = nexus_app.app.dashboard
79+
80+
assert len(dashboard.widgets) > 0
81+
82+
periodic_table = next(w for w in dashboard.widgets if w.type == "periodic_table")
83+
assert periodic_table.search_quantity == "results.material.elements"
84+
assert periodic_table.layout

0 commit comments

Comments
 (0)