# -*- coding: utf-8 -*- # pylint: disable=abstract-method,arguments-differ,redefined-outer-name """Tests for the :mod:`aiida_common_workflows.workflows.relax.workchain` module.""" import pytest from aiida.plugins import WorkflowFactory from aiida_common_workflows.plugins import get_workflow_entry_point_names from aiida_common_workflows.workflows.relax import RelaxInputsGenerator from aiida_common_workflows.workflows.relax.workchain import CommonRelaxWorkChain @pytest.fixture(scope='function', params=get_workflow_entry_point_names('relax')) def workchain(request) -> CommonRelaxWorkChain: """Fixture that parametrizes over all the registered implementations of the ``CommonRelaxWorkChain``.""" return WorkflowFactory(request.param) def test_workchain_class(workchain): """Test that each registered common relax workchain can be imported and subclasses ``CommonRelaxWorkChain``.""" assert issubclass(workchain, CommonRelaxWorkChain) def test_get_inputs_generator(workchain): """Test that each registered common relax workchain defines the associated inputs generator.""" generator = workchain.get_inputs_generator() assert isinstance(generator, RelaxInputsGenerator) assert issubclass(generator.process_class, CommonRelaxWorkChain)
from aiida.engine import WorkChain from aiida.plugins import WorkflowFactory from aiida_common_workflows.plugins import get_workflow_entry_point_names from aiida_common_workflows.workflows import eos from aiida_common_workflows.workflows.relax.workchain import CommonRelaxWorkChain from aiida_common_workflows.workflows.relax.generator import RelaxType @pytest.fixture def ctx(): """Return the context for a port validator.""" return None @pytest.fixture(scope='function', params=get_workflow_entry_point_names('relax')) def common_relax_workchain(request) -> CommonRelaxWorkChain: """Fixture that parametrizes over all the registered implementations of the ``CommonRelaxWorkChain``.""" return WorkflowFactory(request.param) @pytest.mark.usefixtures('with_database') def test_validate_sub_process_class(ctx): """Test the `validate_sub_process_class` validator.""" for value in [None, WorkChain]: message = f'`{value}` is not a valid or registered workflow entry point.' assert eos.validate_sub_process_class(value, ctx) == message @pytest.mark.usefixtures('with_database') def test_validate_sub_process_class_plugins(ctx, common_relax_workchain):