Skip to content

Commit 271c9a9

Browse files
committed
test changing unit cell choices in crystal_toolkit/apps/examples/tests/test_structure.py
1 parent 358acc0 commit 271c9a9

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

crystal_toolkit/apps/examples/tests/test_bandstructure.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import time
22

33
from crystal_toolkit.apps.examples.bandstructure import app
4+
from crystal_toolkit.apps.examples.tests.typing import DashDuo
45

56

6-
def test_bs(dash_duo):
7+
def test_bs(dash_duo: DashDuo) -> None:
78

89
dash_duo.start_server(app)
910
dash_duo.clear_storage()

crystal_toolkit/apps/examples/tests/test_basic.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
app as hello_structure_interactive_app,
88
)
99
from crystal_toolkit.apps.examples.basic_hello_world import app as hello_world_app
10-
11-
from .typing import DashDuo
10+
from crystal_toolkit.apps.examples.tests.typing import DashDuo
1211

1312

1413
def test_hello_scientist(dash_duo: DashDuo):
@@ -19,18 +18,18 @@ def test_hello_scientist(dash_duo: DashDuo):
1918
dash_duo.percy_snapshot("hello_scientist")
2019

2120
logs = dash_duo.get_logs()
22-
assert bool(logs) is False, f"Browser console contains an error: {logs}"
21+
assert logs == [], f"Browser console contains an error: {logs}"
2322

2423

25-
def test_hello_structure(dash_duo):
24+
def test_hello_structure(dash_duo: DashDuo) -> None:
2625
dash_duo.start_server(hello_structure_app)
2726
dash_duo.clear_storage()
2827

2928
time.sleep(1)
3029
dash_duo.percy_snapshot("hello_structure")
3130

3231
logs = dash_duo.get_logs()
33-
assert bool(logs) is False, f"Browser console contains an error: {logs}"
32+
assert logs == [], f"Browser console contains an error: {logs}"
3433

3534

3635
def test_hello_structure_interactive(dash_duo: DashDuo) -> None:
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
import time
1+
from time import sleep
22

33
from crystal_toolkit.apps.examples.structure import app
4+
from crystal_toolkit.apps.examples.tests.typing import DashDuo
45

56

6-
def test_structure(dash_duo):
7+
def test_structure(dash_duo: DashDuo) -> None:
78

89
dash_duo.start_server(app)
910
dash_duo.clear_storage()
1011

11-
time.sleep(5)
1212
dash_duo.percy_snapshot("example_structure_on_load")
13+
sleep(1)
1314

1415
# click the settings button (second button in the button-bar) to show the settings panel
1516
# and test the settings options.
16-
dash_duo.find_elements(".mpc-button-bar .button")[1].click()
17+
dash_duo.find_element(".mpc-button-bar .button[data-for*=settings]").click()
18+
19+
# make sure changing unit cell works
20+
for idx in range(3):
21+
dash_duo.select_dcc_dropdown("#CTmy_structure_unit-cell-choice", index=idx)
22+
dash_duo.percy_snapshot(f"example_structure_unit-cell_index_{idx}")
1723

1824
# test changing radius
19-
el = dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=0)
20-
time.sleep(1)
25+
dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=0)
2126
dash_duo.percy_snapshot("example_structure_radius_index_0")
27+
sleep(1)
2228

2329
# test changing radius again
24-
el = dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=2)
25-
time.sleep(1)
30+
dash_duo.select_dcc_dropdown("#CTmy_structure_radius_strategy", index=2)
2631
dash_duo.percy_snapshot("example_structure_primitive_radius_index_2")
32+
sleep(1)
2733

28-
assert (
29-
bool(dash_duo.get_logs()) is False
30-
), f"Browser console contains an error: {dash_duo.get_logs()}"
34+
logs = dash_duo.get_logs()
35+
assert logs == [], f"Browser console contains an error: {logs}"

0 commit comments

Comments
 (0)