コード例 #1
0
def test_svn_export_retry_success(
    mocker, tmp_path, sample_repo_url, exception_to_retry
):
    svnrepo = SvnRepo(
        sample_repo_url, sample_repo_url, tmp_path, max_content_length=100000
    )

    mock_sleep = mocker.patch.object(svnrepo.export.retry, "sleep")

    nb_failed_calls = 2
    svnrepo.client = SVNClientWrapper(
        svnrepo.client, exception_to_retry, nb_failed_calls
    )

    export_path = os.path.join(tmp_path, "export")
    svnrepo.export(sample_repo_url, export_path)
    assert os.path.exists(export_path)

    assert_sleep_calls(mock_sleep, mocker, nb_failed_calls)
コード例 #2
0
def test_svn_export_retry_failure(
    mocker, tmp_path, sample_repo_url, exception_to_retry
):
    svnrepo = SvnRepo(
        sample_repo_url, sample_repo_url, tmp_path, max_content_length=100000
    )

    mock_sleep = mocker.patch.object(svnrepo.export.retry, "sleep")

    nb_failed_calls = SVN_RETRY_MAX_ATTEMPTS
    svnrepo.client = SVNClientWrapper(
        svnrepo.client, exception_to_retry, nb_failed_calls
    )

    with pytest.raises(type(exception_to_retry)):
        export_path = os.path.join(tmp_path, "export")
        svnrepo.export(sample_repo_url, export_path)

    assert not os.path.exists(export_path)

    assert_sleep_calls(mock_sleep, mocker, nb_failed_calls - 1)