Ejemplo n.º 1
0
def empty_repo(request, tmp_path_factory):
    """Get an empty MetagitRepo."""
    repo_path = tmp_path_factory.mktemp("empty_projects")
    if request.param:
        # .metagit was removed.
        repo = metagit.MetagitRepo.init(repo_path)
        repo.remove_project(repo.metagit_dir)
    else:
        # .metagit was never committed.
        repo = metagit.MetagitRepo(repo_path /
                                   metagit.MetagitRepo.METAGIT_DIR_NAME)
        git.Repo.init(repo.metagit_dir)
    return repo
Ejemplo n.º 2
0
def test_repo_status_invalid_repo(tmp_path):
    """MetagitRepo.status raises an exception if the repo is invalid."""
    repo = api.MetagitRepo(tmp_path / api.MetagitRepo.METAGIT_DIR_NAME)
    with pytest.raises(api.InvalidRepoError, match=str(repo.metagit_dir)):
        repo.status()
Ejemplo n.º 3
0
def test_repo_eq(repo):
    """Distinct MetagitRepo instances for the same repo are equal."""
    assert repo == api.MetagitRepo(repo.metagit_dir)
Ejemplo n.º 4
0
def test_repo_restore_project_invalid_repo(tmp_path, project_type):
    """MetagitRepo.restore_project raises an exception if the repo is invalid."""
    repo = api.MetagitRepo(tmp_path / api.MetagitRepo.METAGIT_DIR_NAME)
    git_repo = git_repo_for_metagit_repo(repo)
    with pytest.raises(api.InvalidRepoError, match=str(repo.metagit_dir)):
        repo.restore_project(project_type(git_repo.git_dir))
Ejemplo n.º 5
0
def test_repo_diff_project_not_in_repo(repo, tmp_path, project_type):
    """MetagitRepo.diff_project raises an exception if a project is not in the repo."""
    git_repo = git_repo_for_metagit_repo(
        api.MetagitRepo(tmp_path / api.MetagitRepo.METAGIT_DIR_NAME), )
    with pytest.raises(api.NotInRepoError, match=str(tmp_path)):
        repo.diff_project(project_type(git_repo.git_dir))