def test_display_name(self): """Check if display name is unquoted and unicode.""" entry = DirEntry(self.root_path, b'my_dir', True, []) self.assertEqual('my_dir', entry.display_name) entry = DirEntry(self.root_path, b'my;090dir', True, []) self.assertEqual('myZdir', entry.display_name)
def test_init(self): entry = DirEntry(self.root_path, b'my_filename.txt', False, []) self.assertFalse(entry.isdir) self.assertFalse(entry.exists) self.assertEqual(os.path.join(b'my_filename.txt'), entry.path) self.assertEqual(os.path.join(self.repo.full_path, b'my_filename.txt'), entry.full_path)
def test_file_size_without_stats(self): increments = [ IncrementEntry(self.root_path, b'my_file.2014-11-05T16:04:30-05:00.dir') ] entry = DirEntry(self.root_path, b'my_file', False, increments) self.assertEqual(0, entry.file_size)
def test_file_size(self): increments = [ IncrementEntry( self.root_path, bytes( '<F!chïer> (@vec) {càraçt#èrë} $épêcial.2014-11-05T16:05:07-05:00.dir', encoding='utf-8')) ] entry = DirEntry( self.root_path, bytes('<F!chïer> (@vec) {càraçt#èrë} $épêcial', encoding='utf-8'), False, increments) self.assertEqual(286, entry.file_size)
def test_change_dates_with_exists(self): """Check if dates are properly sorted.""" increments = [ IncrementEntry( self.root_path, b'my_filename.txt.2014-11-02T17:23:41-05:00.diff.gz'), IncrementEntry( self.root_path, b'my_filename.txt.2014-11-02T09:16:43-05:00.missing'), IncrementEntry( self.root_path, b'my_filename.txt.2014-11-03T19:04:57-05:00.diff.gz') ] entry = DirEntry(self.root_path, b'my_filename.txt', True, increments) self.assertEqual([ RdiffTime('2014-11-02T17:23:41-05:00'), RdiffTime('2014-11-03T19:04:57-05:00') ], entry.change_dates)
def test_change_dates(self): """Check if dates are properly sorted.""" increments = [ IncrementEntry( self.root_path, b'my_filename.txt.2014-11-02T17:23:41-05:00.diff.gz'), IncrementEntry( self.root_path, b'my_filename.txt.2014-11-02T09:16:43-05:00.missing'), IncrementEntry( self.root_path, b'my_filename.txt.2014-11-03T19:04:57-05:00.diff.gz') ] entry = DirEntry(self.root_path, b'my_filename.txt', False, increments) self.assertEqual([ RdiffTime(1414939853), RdiffTime(1414967021), RdiffTime(1415059497) ], entry.change_dates)