コード例 #1
0
ファイル: test_terms.py プロジェクト: darfire/screp
    def test_make_action(self, monkeypatch):
        import screp.actiondir as module
        from screp.term_parser import ParsedTermAction
        from screp.idloc import (
                Identification,
                Location,
                )

        mock_ids = ('action', 'a')
        mock_args = [1, 2, 'three']
        mock_value = 'value'

        def action_builder(identification, args):
            assert type(identification) is Identification

            assert identification.name in mock_ids
            assert identification.type == 'type'

            assert args is mock_args

            return mock_value

        Test_make_action.setup_actions_dir(monkeypatch, [
            (mock_ids,   action_builder),
            ])

        a1 = module.make_action(ParsedTermAction('action',
            Identification('action', 'type', Location('X', 1)), mock_args))

        a2 = module.make_action(ParsedTermAction('a',
            Identification('a', 'type', Location('X', 2)), mock_args))

        assert a1 == mock_value and a2 == mock_value
コード例 #2
0
ファイル: test_terms.py プロジェクト: darfire/screp
    def test_make_action_not_found(self, monkeypatch):
        import screp.actiondir as module
        from screp.term_parser import ParsedTermAction

        Test_make_action.setup_actions_dir(monkeypatch, [
            (('action',),   lambda id, args: 'value'),
            ])

        with pytest.raises(Exception):
            module.make_action(ParsedTermAction('other_action', 1, []))