Skip to content

Commit 79bfdb1

Browse files
Update pytest fixtures (#179)
Co-authored-by: ElliottKasoar <[email protected]>
1 parent 3452896 commit 79bfdb1

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ readme = "README.md"
2121
keywords = ["aiida", "plugin"]
2222

2323
dependencies = [
24-
"aiida-core<3,>=2.6.3",
24+
"aiida-core<3,>=2.7",
2525
"ase<4.0,>=3.24",
2626
"voluptuous<1,>=0.15.2",
2727
"janus-core<0.8,>=0.7.5",

tests/conftest.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,28 @@
1414
from aiida.plugins import CalculationFactory
1515
import pytest
1616

17-
pytest_plugins = ["aiida.manage.tests.pytest_fixtures"]
17+
pytest_plugins = ["aiida.tools.pytest_fixtures"]
1818

1919

2020
@pytest.fixture(scope="function", autouse=True)
2121
def clear_database_auto(aiida_profile_clean):
2222
"""Automatically clear database in between tests."""
2323

2424

25+
@pytest.fixture(scope="session", autouse=True)
26+
def aiida_profile(aiida_config, aiida_profile_factory):
27+
"""
28+
Session-scoped fixture to create an AiiDA profile.
29+
30+
Yields
31+
------
32+
`Profile`
33+
A default profile instance.
34+
"""
35+
with aiida_profile_factory(aiida_config, broker_backend="core.rabbitmq") as profile:
36+
yield profile
37+
38+
2539
@pytest.fixture(scope="session")
2640
def filepath_tests():
2741
"""
@@ -82,7 +96,7 @@ def fixture_localhost(aiida_localhost):
8296

8397

8498
@pytest.fixture(scope="function")
85-
def janus_code(aiida_local_code_factory):
99+
def janus_code(aiida_code_installed):
86100
"""
87101
Fixture to get the janus code.
88102
@@ -97,7 +111,12 @@ def janus_code(aiida_local_code_factory):
97111
The janus code instance.
98112
"""
99113
janus_path = shutil.which("janus") or os.environ.get("JANUS_PATH")
100-
return aiida_local_code_factory(executable=janus_path, entry_point="mlip.sp")
114+
115+
return aiida_code_installed(
116+
label="janus",
117+
default_calc_job_plugin="mlip.sp",
118+
filepath_executable=janus_path,
119+
)
101120

102121

103122
@pytest.fixture

tests/workflows/test_ht.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
import pytest
88

99
from aiida_mlip.data.model import ModelData
10-
from aiida_mlip.workflows.ht_workgraph import build_ht_calc
1110

1211

1312
def test_ht_singlepoint(janus_code, workflow_structure_folder, model_folder) -> None:
1413
"""Test high throughput singlepoint calculation."""
14+
from aiida_mlip.workflows.ht_workgraph import build_ht_calc
15+
1516
SinglepointCalc = CalculationFactory("mlip.sp")
1617

1718
model_file = model_folder / "mace_mp_small.model"
@@ -38,6 +39,8 @@ def test_ht_singlepoint(janus_code, workflow_structure_folder, model_folder) ->
3839

3940
def test_ht_invalid_path(janus_code, workflow_invalid_folder, model_folder) -> None:
4041
"""Test invalid path for high throughput calculation."""
42+
from aiida_mlip.workflows.ht_workgraph import build_ht_calc
43+
4144
SinglepointCalc = CalculationFactory("mlip.sp")
4245

4346
model_file = model_folder / "mace_mp_small.model"
@@ -58,6 +61,8 @@ def test_ht_invalid_path(janus_code, workflow_invalid_folder, model_folder) -> N
5861

5962
def test_ht_geomopt(janus_code, workflow_structure_folder, model_folder) -> None:
6063
"""Test high throughput geometry optimisation."""
64+
from aiida_mlip.workflows.ht_workgraph import build_ht_calc
65+
6166
GeomoptCalc = CalculationFactory("mlip.opt")
6267

6368
model_file = model_folder / "mace_mp_small.model"

0 commit comments

Comments
 (0)