def test_checkout(self): """Test whether Git checkout commands are correctly executed""" new_path = os.path.join(self.tmp_path, 'testworktree') repo = GraalRepository('http://example.git', self.git_path) self.assertIsNone(repo.worktreepath) repo.worktree(new_path) repo.checkout("075f0c6161db5a3b1c8eca45e08b88469bb148b9") current_commit_hash = self.__git_show_hash(repo) self.assertEqual("075f0c6161db5a3b1c8eca45e08b88469bb148b9", current_commit_hash) repo.checkout("4f3b403d47fb291a9a942a62d62c24faa79244c8") current_commit_hash = self.__git_show_hash(repo) self.assertEqual("4f3b403d47fb291a9a942a62d62c24faa79244c8", current_commit_hash) repo.checkout("825b4da7ca740f7f2abbae1b3402908a44d130cd") current_commit_hash = self.__git_show_hash(repo) self.assertEqual("825b4da7ca740f7f2abbae1b3402908a44d130cd", current_commit_hash) repo.prune() self.assertFalse(os.path.exists(repo.worktreepath))
def test_files_no_dir(self): """Test whether an empty list is returned when the input is none""" repo = GraalRepository('http://example.git', self.git_path) files = repo.files(None) self.assertEqual(files, [])
def __init__(self, exec_path): if not GraalRepository.exists(exec_path): raise GraalError(cause="executable path %s not valid" % exec_path) self.exec_path = exec_path
def test_extension(self): """Test whether file extensions are identified""" self.assertEqual(GraalRepository.extension('setup.py'), 'py') self.assertEqual(GraalRepository.extension('tests/requirements.txt'), 'txt') self.assertEqual(GraalRepository.extension('LICENSE'), 'LICENSE')