def filled_repo(repo_dir, home_dir): """Moredots repository with at least one dotfile.""" repo = DotfileRepo.init(repo_dir, home_dir) # add some dotfiles (both in root and inside dot-directories) for _ in xrange(random.randint(1, 3)): repo.add(dotfile_in_home(home_dir, dotfile_name())) for _ in xrange(random.randint(1, 3)): dotdir_file = dotdir_file_in_home(dotdir_in_home(home_dir), filename()) repo.add(dotdir_file) return repo
def test_init_in_existing_repo(self, empty_repo): with pytest.raises(exc.RepositoryExistsError): DotfileRepo.init(empty_repo.dir)
def test_init_in_invalid_home_dir(self, repo_dir): with pytest.raises(exc.InvalidHomeDirError): DotfileRepo.init(repo_dir, home_dir=repo_dir)
def test_init_persists_home_dir(self, repo_dir, home_dir): repo1 = DotfileRepo.init(repo_dir, home_dir) repo2 = DotfileRepo(repo_dir) # from existing repo assert repo1.home_dir == repo2.home_dir
def test_init_basics(self, repo_dir, home_dir): repo = DotfileRepo.init(repo_dir, home_dir) assert repo.dir == repo_dir assert repo.home_dir == home_dir
def handle_install(remote_url, repo_dir, home_dir): """Installs remote dotfiles repository on this machine.""" DotfileRepo.install(remote_url, repo_dir, home_dir)
def handle_init(repo_dir, home_dir): """Initialize dotfiles repository.""" DotfileRepo.init(repo_dir, home_dir)
def test_install_basics(self, empty_remote_url, repo_dir, home_dir): repo = DotfileRepo.install(empty_remote_url, repo_dir, home_dir) assert repo.dir == repo_dir assert repo.home_dir == home_dir
def test_install_filled(self, filled_remote_url, repo_dir, home_dir): repo = DotfileRepo.install(filled_remote_url, repo_dir, home_dir) assert len(list(repo.dotfiles)) > 0
def test_install_empty(self, empty_remote_url, repo_dir, home_dir): repo = DotfileRepo.install(empty_remote_url, repo_dir, home_dir) assert len(list(repo.dotfiles)) == 0
def test_install_adds_git_remote(self, filled_remote_url, repo_dir, home_dir): repo = DotfileRepo.install(filled_remote_url, repo_dir, home_dir) origin = repo.git_repo.remotes.origin assert origin.url == filled_remote_url assert len(origin.refs) > 0
def empty_repo(repo_dir, home_dir): """Empty moredots repository.""" return DotfileRepo.init(repo_dir, home_dir)