Пример #1
0
def test_get_pakkr_depth_not_found_no_pipeline(mock_inspect):
    pipeline_1 = Mock(spec=Pipeline)

    mock_stack = [_FrameInfo(_Frame({}), 'some_external_func_1'),
                  _FrameInfo(_Frame({}), 'some_external_func_2')]
    mock_inspect.stack.return_value = mock_stack

    depth, used_as_step = _get_pakkr_depth(pipeline_1)
    assert depth == -1
    assert used_as_step is False
Пример #2
0
def test_get_pakkr_depth_0(mock_inspect):
    pipeline_1 = Mock(spec=Pipeline)

    mock_stack = [_FrameInfo(_Frame({'self': pipeline_1}), '__call__'),
                  _FrameInfo(_Frame({}), 'some_external_func_1'),
                  _FrameInfo(_Frame({'self': Mock()}), 'some_method'),
                  _FrameInfo(_Frame({}), 'some_external_func_2')]
    mock_inspect.stack.return_value = mock_stack
    depth, used_as_step = _get_pakkr_depth(pipeline_1)
    assert depth == 0
    assert used_as_step is False
Пример #3
0
def test_get_pakkr_depth_not_found_with_pipeline(mock_inspect):
    pipeline_1 = Mock(spec=Pipeline)
    pipeline_2 = Mock(spec=Pipeline)

    mock_stack = [
        _FrameInfo(_Frame({}), 'some_external_func_1'),
        _FrameInfo(_Frame({}), 'some_external_func_2'),
        _FrameInfo(_Frame({'self': pipeline_2}), '_run_step'),
        _FrameInfo(_Frame({'self': pipeline_2}), '__call__')
    ]
    mock_inspect.stack.return_value = mock_stack

    depth, used_as_step = _get_pakkr_depth(pipeline_1)
    assert depth == -1
    assert used_as_step is None
Пример #4
0
def test_get_pakkr_depth_1_as_step_in_between(mock_inspect):
    pipeline_1 = Mock(spec=Pipeline)
    pipeline_2 = Mock(spec=Pipeline)
    pipeline_3 = Mock(spec=Pipeline)

    mock_stack = [_FrameInfo(_Frame({'self': pipeline_1}), '__call__'),
                  _FrameInfo(_Frame({'self': pipeline_2}), '_run_step'),
                  _FrameInfo(_Frame({'self': pipeline_2}), '__call__'),
                  _FrameInfo(_Frame({'self': pipeline_3}), '_run_step'),
                  _FrameInfo(_Frame({'self': pipeline_3}), '__call__'),
                  _FrameInfo(_Frame({}), 'some_external_func_1')]
    mock_inspect.stack.return_value = mock_stack

    depth, used_as_step = _get_pakkr_depth(pipeline_2)
    assert depth == 1
    assert used_as_step is True