コード例 #1
0
ファイル: test_git.py プロジェクト: bmwcarit/zubbi
def test_file_contents(mock_git_repo, tmpdir):
    git_url = "https://localhost/git"
    repo_name = "foo"

    with mock_git_repo(tmpdir, repo_name, git_url):
        git_con = GitConnection(git_url, workspace=tmpdir)
        git_repo = GitRepository(repo_name, git_con)

        contents = git_repo.file_contents("README")
        assert contents == "Repository: foo"
コード例 #2
0
ファイル: test_git.py プロジェクト: bmwcarit/zubbi
def test_non_existing_file_contents(mock_git_repo, tmpdir):
    git_url = "https://localhost/git"
    repo_name = "foo"

    with mock_git_repo(tmpdir, repo_name, git_url):
        git_con = GitConnection(git_url, workspace=tmpdir)
        git_repo = GitRepository(repo_name, git_con)

        with pytest.raises(CheckoutError) as excinfo:
            git_repo.file_contents("non-existing-file")
        assert "Failed to check out 'non-existing-file'" in str(excinfo.value)
コード例 #3
0
ファイル: test_git.py プロジェクト: bmwcarit/zubbi
def test_directory_contents(mock_git_repo, tmpdir):
    git_url = "https://localhost/git"
    repo_name = "foo"

    with mock_git_repo(tmpdir, repo_name, git_url):
        git_con = GitConnection(git_url, workspace=tmpdir)
        git_repo = GitRepository(repo_name, git_con)

        contents = git_repo.directory_contents("/")
        # The contents dict should contain an entry for the README file
        readme_contents = contents["README"]
        assert isinstance(readme_contents, FileContent)
        assert readme_contents.path == "README"
コード例 #4
0
ファイル: test_git.py プロジェクト: bmwcarit/zubbi
def test_get_repo_object_failure(tmpdir):
    git_url = "https://localhost/git"
    repo_name = "foo"

    git_con = GitConnection(git_url, workspace=tmpdir)
    git_repo = GitRepository(repo_name, git_con)
    assert git_repo._repo is None
コード例 #5
0
ファイル: test_git.py プロジェクト: bmwcarit/zubbi
def test_get_repo_object_existing_path(mock_git_repo, tmpdir):
    git_url = "https://localhost/git"
    repo_name = "foo"

    with mock_git_repo(tmpdir, repo_name, git_url):
        git_con = GitConnection(git_url, workspace=tmpdir)
        # The __init__() method calls _get_repo_object()
        git_repo = GitRepository(repo_name, git_con)
        assert isinstance(git_repo._repo, Repo)