def testProperties(self): wd = WatchDirectory("/test/one") self.assertEquals(wd.path, "/test/one/") wd.watcher = "x" self.assertEquals(wd.watcher, "x") wd.ignoreFileFilter = "*.tmp|test" self.assertEquals(wd.ignoreFileFilter, "*.tmp|test") wd.ignoreDirectories="temp|tmp" self.assertEquals(wd.ignoreDirectories, "temp|tmp")
def testFilter(self): wd = WatchDirectory("/test/one/") wd.ignoreFileFilter = "*.tmp|test" wd.ignoreDirectories="temp|tmp|one" self.assertTrue(wd.filter("/test/one/test.txt")) self.assertFalse(wd.filter("/test/one/test.tmp")) self.assertFalse(wd.filter("/test/one/subdir/one/test.txt"))
def testListenerUpdateHandler(self): # updateHandler(file, eventTime, eventName, isDir=False, walk=False) wd = WatchDirectory("/test/one/") wd.ignoreFileFilter = "*.tmp|test" wd.ignoreDirectories="temp|tmp|one" files = [] def listener(file, eventTime, eventName, isDir=False, walk=False): files.append(file) wd.addListener(listener) wd.updateHandler("/test/one/file1", 42L, "eName", isDir=False, walk=False) wd.updateHandler("/test/one/ignore.tmp", 42L, "eName", isDir=False, walk=False) wd.updateHandler("/test/one/temp/ignore", 42L, "eName", isDir=False, walk=False) wd.updateHandler("/test/one/subdir/file1", 42L, "eName", isDir=False, walk=False) self.assertEquals(len(files), 2)