def test_content_from_index_read_without_git_add(self): ctx = FileCtx(self.repo, self.changectx, self.file_name, True) self.assertEqual(ctx.content, 'test\n') with codecs.open(self.file_path, 'a', encoding='utf-8') as fp: fp.write('lol\n') # change file without git add ctx = FileCtx(self.repo, self.changectx, self.file_name, True) self.assertEqual(ctx.content, 'test\nlol\n')
def test_date_and_mdate(self): ctx = FileCtx(self.repo, self.changectx, self.file_name) time.sleep(1) self.assertTrue(ctx.date < time.time()) self.assertTrue(ctx.mdate is None) old_date = ctx.date time.sleep(1) with codecs.open(self.file_path, 'a', encoding='utf-8') as fp: fp.write('foo\n') git_commit(self.repo, self.tree, [self.file_name], [self.last_commit]) ctx = FileCtx(self.repo, self.changectx, self.file_name) self.assertEqual(ctx.date, old_date) self.assertTrue(ctx.mdate > old_date)
def get_filectx(self, path): return FileCtx(self._repo, self._ctx, path)
def get_filectx(self, path): return FileCtx(self._repo, self._ctx, path, use_index=True)
def test_author(self): ctx = FileCtx(self.repo, self.changectx, self.file_name) self.assertEqual(ctx.author, 'foo <*****@*****.**>')
def test_path(self): ctx = FileCtx(self.repo, self.changectx, self.file_name) self.assertEqual(ctx.path, 'foo.rst')