aiida.backends.tests.utils package

Submodules

Test utility to import, inspect, or migrate AiiDA export archives.

aiida.backends.tests.utils.archives.get_archive_file(archive, filepath=None, external_module=None)[source]

Return the absolute path of the archive file used for testing purposes. The expected path for these files:

aiida.backends.tests.fixtures.filepath
Parameters:
  • archive – the relative filename of the archive
  • filepath – str of directories of where to find archive (starting “/”s are irrelevant)
  • external_module – string with name of external module, where archive can be found
Returns:

absolute filepath of the archive test file

aiida.backends.tests.utils.archives.get_json_files(archive, silent=True, filepath=None, external_module=None)[source]

Get metadata.json and data.json from an exported AiiDA archive

Parameters:
  • archive – the relative filename of the archive
  • silent – Whether or not the extraction should be silent
  • filepath – str of directories of where to find archive (starting “/”s are irrelevant)
  • external_module – string with name of external module, where archive can be found
aiida.backends.tests.utils.archives.import_archive(archive, filepath=None, external_module=None)[source]

Import a test archive that is an AiiDA export archive

Parameters:
  • archive – the relative filename of the archive
  • filepath – str of directories of where to find archive (starting “/”s are irrelevant)
  • external_module – string with name of external module, where archive can be found
aiida.backends.tests.utils.archives.migrate_archive(input_file, output_file, silent=True)[source]

Migrate contents using migrate_recursively This is essentially similar to verdi export migrate. However, since this command may be disabled, this function simulates it and keeps the tests working.

Parameters:
  • input_file – filename with full path for archive to be migrated
  • output_file – filename with full path for archive to be created after migration

Module that defines methods to mock an AiiDA instance complete with mock configuration and profile.

aiida.backends.tests.utils.configuration.create_mock_profile(name, repository_dirpath=None, **kwargs)[source]

Create mock profile for testing purposes.

Parameters:
  • name – name of the profile
  • repository_dirpath – optional absolute path to use as the base for the repository path
aiida.backends.tests.utils.configuration.temporary_config_instance()[source]

Create a temporary AiiDA instance.

aiida.backends.tests.utils.configuration.temporary_directory()[source]

Create a temporary directory.

aiida.backends.tests.utils.configuration.with_temp_dir(function)[source]

Create a temporary directory for the duration of the wrapped function.

The path of the temporary directory is passed to the wrapped function via the ‘temp_dir’ parameter (which it must accept).

aiida.backends.tests.utils.configuration.with_temporary_config_instance(function)[source]

Create a temporary AiiDA instance for the duration of the wrapped function.

Utilities for testing components from the workflow engine

class aiida.backends.tests.utils.processes.AddProcess(inputs=None, logger=None, runner=None, parent_pid=None, enable_persistence=True)[source]

Bases: aiida.engine.processes.process.Process

A simple Process that adds two integers.

__abstractmethods__ = frozenset()
__module__ = 'aiida.backends.tests.utils.processes'
_abc_impl = <_abc_data object>
_node_class

alias of aiida.orm.nodes.process.workflow.workflow.WorkflowNode

classmethod define(spec)[source]
run()[source]
class aiida.backends.tests.utils.processes.BadOutput(inputs=None, logger=None, runner=None, parent_pid=None, enable_persistence=True)[source]

Bases: aiida.engine.processes.process.Process

A Process that emits an output that isn’t an AiiDA Data type.

__abstractmethods__ = frozenset()
__module__ = 'aiida.backends.tests.utils.processes'
_abc_impl = <_abc_data object>
_node_class

alias of aiida.orm.nodes.process.workflow.workflow.WorkflowNode

classmethod define(spec)[source]
run()[source]
class aiida.backends.tests.utils.processes.DummyProcess(inputs=None, logger=None, runner=None, parent_pid=None, enable_persistence=True)[source]

Bases: aiida.engine.processes.process.Process

A Process that does nothing when it runs.

__abstractmethods__ = frozenset()
__module__ = 'aiida.backends.tests.utils.processes'
_abc_impl = <_abc_data object>
_node_class

alias of aiida.orm.nodes.process.workflow.workflow.WorkflowNode

classmethod define(spec)[source]
run()[source]
class aiida.backends.tests.utils.processes.ExceptionProcess(inputs=None, logger=None, runner=None, parent_pid=None, enable_persistence=True)[source]

Bases: aiida.engine.processes.process.Process

A Process that raises a RuntimeError when run.

__abstractmethods__ = frozenset()
__module__ = 'aiida.backends.tests.utils.processes'
_abc_impl = <_abc_data object>
_node_class

alias of aiida.orm.nodes.process.workflow.workflow.WorkflowNode

run()[source]
class aiida.backends.tests.utils.processes.WaitProcess(inputs=None, logger=None, runner=None, parent_pid=None, enable_persistence=True)[source]

Bases: aiida.engine.processes.process.Process

A Process that waits until it is asked to continue.

__abstractmethods__ = frozenset()
__module__ = 'aiida.backends.tests.utils.processes'
_abc_impl = <_abc_data object>
_node_class

alias of aiida.orm.nodes.process.workflow.workflow.WorkflowNode

next_step()[source]
run()[source]