Ejemplo n.º 1
0
    def test_register_complex_action(self):
        # check registration of complex action: two actions with the same itype
        # but different fields
        registry = ActionsRegistry()

        registry.register_action(IfTestAction)
        registry.register_action(ElseTestAction)

        # check that get methods work
        params = {
            'WFWorkflowActionParameters': {
                'WFControlFlowMode': IfTestAction.default_fields['WFControlFlowMode'],
            }
        }
        assert registry.get_by_itype(IfTestAction.itype, action_params=params) == IfTestAction
        assert registry.get_by_keyword(IfTestAction.keyword) == IfTestAction

        params = {
            'WFWorkflowActionParameters': {
                'WFControlFlowMode': ElseTestAction.default_fields['WFControlFlowMode'],
            }
        }
        assert registry.get_by_itype(ElseTestAction.itype, action_params=params) == ElseTestAction
        assert registry.get_by_keyword(ElseTestAction.keyword) == ElseTestAction

        # check internal structures
        assert registry._keyword_to_action_map == {
            'if': IfTestAction,
            'else': ElseTestAction,
        }
        assert registry._itype_to_action_map == {
            'sh.aleks.if': {
                'type': 'property_based',
                'field': 'WFControlFlowMode',
                'value': {
                    0: IfTestAction,
                    1: ElseTestAction,
                },
            },
        }
Ejemplo n.º 2
0
    def test_register_simple_action(self):
        registry = ActionsRegistry()

        registry.register_action(SimpleTestAction)

        # check that get methods work
        assert registry.get_by_itype(SimpleTestAction.itype, action_params=None) == SimpleTestAction
        assert registry.get_by_keyword(SimpleTestAction.keyword) == SimpleTestAction

        # check internal structures
        assert registry._keyword_to_action_map == {
            'simple_action': SimpleTestAction,
        }
        assert registry._itype_to_action_map == {
            'sh.aleks.simple_action': {
                'type': 'class',
                'value': SimpleTestAction,
            }
        }