-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconftest.py
59 lines (47 loc) · 1.62 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
For pytest
initialise a test database and profile
"""
from __future__ import absolute_import
import os
from pathlib import Path
import pytest
from aiida_ddec.calculations import DENSITY_DIR_EXTRA, DENSITY_DIR_SYMLINK
EXAMPLES_DATA_DIR = Path(__file__).resolve().parent / "examples" / "data"
DATA_DIR = Path(__file__).resolve().parent / "tests" / "data"
@pytest.fixture(scope="function", autouse=True)
def clear_database_auto(clear_database): # pylint: disable=unused-argument
"""Automatically clear database in between tests."""
@pytest.fixture(scope="function")
def ddec_code(mock_code_factory):
"""Create mocked "DDEC" code."""
code = mock_code_factory(
label="chargemol-09_26_2017",
data_dir_abspath=DATA_DIR,
entry_point="ddec",
# files *not* to copy into the data directory
ignore_paths=("_aiidasubmit.sh", "*.cube", DENSITY_DIR_SYMLINK),
)
# Set atomic density directory extra on code
density_dir = os.environ.get(DENSITY_DIR_EXTRA)
if not density_dir:
density_dir = EXAMPLES_DATA_DIR / "ddec" / "atomic_densities"
code.set_extra(DENSITY_DIR_EXTRA, str(density_dir))
return code
@pytest.fixture(scope="function")
def cp2k_code(mock_code_factory):
"""Create mocked "cp2k" code."""
return mock_code_factory(
label="cp2k-7.1",
data_dir_abspath=DATA_DIR,
entry_point="cp2k",
# files *not* to copy into the data directory
ignore_paths=(
"_aiidasubmit.sh",
"BASIS_MOLOPT",
"GTH_POTENTIALS",
"dftd3.dat",
"*.bak*",
"*.wfn",
),
)