Writing tests
Tests are written using pytest.
aiida_profile
fixture is defined in aiida-core with scope='session'
and returns an instance of TestManager
class in aiida-core. aiida_profile
is usually invisible from aiida-vasp test users, but automatically activated by @pytest.fixture(scope='session', autouse=True)
. In aiida-vasp, aiida_profile
is activated in conftest.py
via pytest_plugins
that imports aiida-core's pytest_fixtures.py
(see conftest.py
).
This is used like @pytest.mark.usefixtures('fresh_aiida_env')
. This fixture gets aiida_profile
fixture by fresh_aiida_env(aiida_profile)
. The job of fresh_aiida_env
is to reset aiida-profile DB after using it.
mock_vasp
is a mock of aiida code
of VASP. The details may be found at aiida_vasp.utils.fixtures.data::_mock_vasp
. Shortly, _mock_vasp
returns an aiida-vasp vasp.vasp
plugin code
. In the returned code
, the path to mock-vasp
command is set as the "Remote absolute path". The mock-vasp
command (aiida_vasp.commands.mock_vasp::mock_vasp
-> @click.command('mock-vasp')
) is installed in the process of aiida-vasp installation.
Additional information about click:
- https://click.palletsprojects.com/en/8.0.x/setuptools/
- https://click.palletsprojects.com/en/8.0.x/api/#commands
Location:
aiida_vasp.utils.fixtures
aiida_vasp.parsers.tests.test_vasp_parser
Some important fixtures are shown below shortly.
A function that returns VaspCalculation
node. More specifically, this function gets a folder path (FolderData
) and input settings
(Dict
), stores them in temporary DB, makes them linked to the node, and finally returns the node.
VaspParser
instance with the node given by the fixture calc_with_retrieved
. The folder path and settings
are set in _get_vasp_parser(calc_with_retrieved)
.