def test_error_on_retry_exceeded(mocky):
    mocky.side_effect = [
        Result(1, 'fake-stdout', ''),
        Result(1, 'fake-stdout', '')
    ]
    with pytest.raises(ExecutionError):
        Executor().run('test-cmd', retries=1)
def test_retry_on_fail(mocky):
    mocky.side_effect = [
        Result(1, 'fake-stdout', ''),
        Result(0, 'fake-stdout', '')
    ]
    Executor().run('test-cmd', retries=1)
    expected = [mock.call('test-cmd'), mock.call('test-cmd')]
    assert mocky.mock_calls == expected
예제 #3
0
def test_next_release(mock_exec, curr_release, next_release):
    mock_exec.return_value.run.return_value = Result(0, curr_release + '\n', '')
    assert ReleaseReader('test-path').get_next_release_label() == next_release
    mock_exec.assert_called_once_with(chdir='test-path')
    mock_exec.return_value.run.assert_called_once_with(['git', 'describe', '--tags', '--abbrev=0'])
def test_no_retry_on_success(mocky):
    mocky.side_effect = [Result(0, 'fake-stdout', '')]
    Executor().run('test-cmd', retries=1)
    mocky.assert_called_once_with('test-cmd')
def test_success_ignore_stderr(mocky):
    mocky.side_effect = [Result(0, 'fake-stdout', 'fake-stderr')]
    Executor().run('test-cmd', raise_on_stderr=False)
    mocky.assert_called_once_with('test-cmd')
def test_success_ignore_returncode(mocky):
    mocky.side_effect = [Result(1, 'fake-stdout', '')]
    Executor().run('test-cmd', raise_on_error=False)
    mocky.assert_called_once_with('test-cmd')
def test_fail_stderr(mocky):
    mocky.side_effect = [Result(0, 'fake-stdout', 'fake-stderr')]
    with pytest.raises(ExecutionError, match=r'stderr not empty'):
        Executor().run('test-cmd')
    mocky.assert_called_once_with('test-cmd')
def test_fail_returncode(mocky):
    mocky.side_effect = [Result(1, 'fake-stdout', '')]
    with pytest.raises(ExecutionError, match=r'execution status NOT zero'):
        Executor().run('test-cmd')
    mocky.assert_called_once_with('test-cmd')