def test_dir_handler(self): handler = DirHandler(self.selector, "", self.protocol, self.config, self.stat_result, self.vfs) self.assertTrue(handler.canhandlerequest()) self.assertTrue(handler.isdir()) handler.prepare() self.assertFalse(handler.fromcache) entry = handler.getentry() self.assertEqual(entry.mimetype, "application/gopher-menu") self.assertEqual(entry.type, "1") entries = handler.getdirlist() self.assertTrue(entries) # Create a second handler to test that it will load from the cached # file that the first handler should have created handler = DirHandler(self.selector, "", self.protocol, self.config, self.stat_result, self.vfs) handler.prepare() self.assertTrue(handler.fromcache) cached_entries = handler.getdirlist() for a, b in zip(entries, cached_entries): self.assertEqual(a.selector, b.selector)
def prepare(self): """Override parent to do a few more things and override sort order.""" # Initialize. self.linkentries = [] # Let the parent do the directory walking for us. Will call # prep_initfiles_canaddfile and prep_entriesappend. if DirHandler.prepare(self): # Returns 1 if it didn't load from the cache. # Merge and sort. self.MergeLinkFiles()
def prepare(self): """Override parent to do a few more things and override sort order.""" # Initialize. self.linkentries = [] # Let the parent do the directory walking for us. Will call # prep_initfiles_canaddfile and prep_entriesappend. if DirHandler.prepare(self): # Returns 1 if it didn't load from the cache. # Merge and sort. self.MergeLinkFiles() self.fileentries.sort(self.entrycmp)