def test_gitrevert(self): '''Make sure we can revert file.''' gitpath = self.get_tmpdir() git = GitIntegration(gitpath) # create a new file newfile, oldcontent = self.create_file(gitpath) git.update_file(newfile) # change file content newcontent = self.change_content(gitpath, newfile) git.update_file(newfile) # check changes is not empty commits = git.get_changes(newfile) self.assertEqual(type(commits), list) self.assertTrue(len(commits) > 0) # revert the file and get content commit = commits[0]['commit'] git.revert_file(newfile, commit) revcontent = self.get_content(gitpath, newfile) # check reverted file's content is the same as initial content self.assertEqual(revcontent, oldcontent) self.clean(gitpath)
def test_githistory(self): '''Make sure we're able to retrieve old version of files.''' gitpath = self.get_tmpdir() git = GitIntegration(gitpath) # create a new file newfile, _ = self.create_file(gitpath) git.update_file(newfile) # change file's content newcontent = self.change_content(gitpath, newfile) git.update_file(newfile) # check file history is not empty self.assertTrue(git.get_changes(newfile) != []) self.clean(gitpath)