def test_list_commits_timeout(requests_mock):
    requests_mock.register_uri("GET",
                               url,
                               exc=requests.exceptions.ConnectTimeout)
    repo = GitHubRepositoryAdapter(base)
    with pytest.raises(git.GitError):
        list(repo.list_commits())
def test_list_commits_error_json(requests_mock):
    requests_mock.register_uri("GET",
                               url,
                               status_code=402,
                               text='{"message": "error"}')
    repo = GitHubRepositoryAdapter(base)
    with pytest.raises(git.GitError):
        list(repo.list_commits())
Esempio n. 3
0
def test_factory_path():
    path = "."
    assert not GitHubRepositoryAdapter.valid_url(path)
    repo, fallback = git.repository_factory(path)
    assert isinstance(repo, LocalGitRepositoryAdapter)
    assert fallback is None
Esempio n. 4
0
def test_factory_ssh_url():
    url = "[email protected]:user/project.git"
    assert GitHubRepositoryAdapter.valid_url(url)
    repo, fallback = git.repository_factory(url)
    assert isinstance(repo, GitHubRepositoryAdapter)
    assert isinstance(fallback, LocalGitRepositoryAdapter)
def test_list_commits_repository_with_fallback():
    url = "https://github.com/mellon85/JavaArrayAccessAnalyzer.git"
    repo = GitHubRepositoryAdapter(url)
    fallback = LocalGitRepositoryAdapter(url)
    assert list(fallback.list_commits()) == list(repo.list_commits())
def test_list_commits_empty_repo():
    repo = GitHubRepositoryAdapter("https://github.com/mellon85/test.git")
    with pytest.raises(git.GitError):
        list(repo.list_commits())