-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
60 lines (43 loc) · 1.39 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
60
"""
For pytest
initialise a text database and profile
"""
from __future__ import absolute_import
import tempfile
import shutil
import pytest
from aiida.manage.fixtures import fixture_manager
@pytest.fixture(scope='session', autouse=True)
def aiida_profile():
"""Set up a test profile for the duration of the tests"""
with fixture_manager() as fixture_mgr:
yield fixture_mgr
@pytest.fixture(scope='function', autouse=True)
def clear_database(aiida_profile):
"""Clear the database after each test"""
yield
aiida_profile.reset_db()
@pytest.fixture(scope='function')
def new_workdir():
"""Get a temporary folder to use as the computer's work directory."""
dirpath = tempfile.mkdtemp()
yield dirpath
shutil.rmtree(dirpath)
@pytest.fixture(scope='function')
def aiida_localhost_computer(new_workdir):
"""Get an AiiDA computer for localhost.
:return: The computer node
:rtype: :py:class:`aiida.orm.Computer`
"""
from aiida_sirius.helpers import get_computer
computer = get_computer(workdir=new_workdir)
return computer
@pytest.fixture(scope='function')
def aiida_code(aiida_localhost_computer):
"""Get an AiiDA code.
:return: The code node
:rtype: :py:class:`aiida.orm.Code`
"""
from aiida_sirius.helpers import get_code
code = get_code(entry_point='sirius.scf', computer=aiida_localhost_computer)
return code