Beispiel #1
0
    def test_extra_kwargs(self):
        m = Mock()
        m._accepts_context = False
        m.return_value = {'returned': 'bar'}
        ctx = DefaultContext()
        with patch('inspect.getargspec') as argspec:
            argspec.return_value = [[]]
            Step(m, extra_kwargs=dict(meow=True))(ctx)

        assert m.called
        m.assert_called_once_with(meow=True)
Beispiel #2
0
    def test_arg_mapper_custom(self):
        m = Mock()
        m._accepts_context = None
        m_cm = Mock(return_value={'moo': True})
        ctx = DefaultContext()
        with patch('inspect.getargspec') as argspec:
            argspec.return_value = [[]]
            Step(m, arg_map=m_cm)(ctx)

        assert m.called
        m.assert_called_once_with(**m_cm.return_value)
Beispiel #3
0
    def test_arg_mapper(self):
        m = Mock()
        m._accepts_context = False
        ctx = DefaultContext()
        ctx.message = 1
        ctx.meow = 1

        with patch('inspect.getargspec') as argspec:
            argspec.return_value = [[]]
            Step(m, arg_map={'message': 'message'})(ctx)
            Step(m, arg_map={'meow': 'message'})(ctx)

        assert m.called
        m.assert_any_call(message=1)
        m.assert_any_call(meow=1)
Beispiel #4
0
    def test_call_context(self):
        m = Mock()
        m._accepts_context = True
        ctx = DefaultContext()
        with patch('inspect.getargspec') as argspec:
            argspec.return_value = [[]]
            Step(m)(ctx)

        assert m.called
        m.assert_called_once_with(context=ctx)
        m.reset_mock()

        with patch('inspect.getargspec') as argspec:
            argspec.return_value = [['context']]
            Step(m)(ctx)

        assert m.called
        m.assert_called_once_with(context=ctx)