def test_file_add(self):
     self.queue = Queue.Queue(0)
     dir = '/home/eric/Desktop'
     file_input_watcher = FileInputWatcher(dir, self.queue)
     if os.path.isfile("/home/eric/Desktop/anyfile") is True:
         os.remove('/home/eric/Desktop/anyfile')
     #Start a monitoring thread.  It ends on its own.
     file_input_watcher.monitor()
     #now make a file whilst pyinotify thread is running
     sleep(1)
     #no file is sent
     try:
         result = self.queue.get(block='true', timeout=5)
     except Queue.Empty:
         result = None
     file_input_watcher.stop_monitoring()
     #clean up file mess created
     if os.path.isfile("/home/eric/Desktop/anyfile") is True:
         os.remove('/home/eric/Desktop/anyfile')
     self.assertEqual(result, None)
Ejemplo n.º 2
0
 def test_file_add(self):
     self.queue = Queue.Queue(0)
     dir = '/home/eric/Desktop'
     file_input_watcher = FileInputWatcher(dir, self.queue)
     if os.path.isfile("/home/eric/Desktop/anyfile") is True:
         os.remove('/home/eric/Desktop/anyfile')
     #Start a monitoring thread.  It ends on its own.
     file_input_watcher.monitor()
     #now make a file whilst pyinotify thread is running
     sleep(1)
     #no file is sent
     try:
         result = self.queue.get(block='true', timeout=5)
     except Queue.Empty:
         result = None
     file_input_watcher.stop_monitoring()
     #clean up file mess created
     if os.path.isfile("/home/eric/Desktop/anyfile") is True:
         os.remove('/home/eric/Desktop/anyfile')
     self.assertEqual(result, None)
 def test_file_add(self):
     self.queue = Queue.Queue(0)
     dir = testcase_settings.INPUTFILES_PATH
     testFile = testcase_settings.TEST_FILE
     file_input_watcher = FileInputWatcher(dir, self.queue)
     if os.path.isfile(os.path.join(dir, testFile)) is True:
         os.remove(os.path.join(dir, testFile))
     #Start a monitoring thread.  It ends on its own.
     file_input_watcher.monitor()
     #now make a file whilst pyinotify thread is running
     sleep(1)
     f = open(os.path.join(dir, testFile),'w')
     f.close()
     result = self.queue.get(block='true')
     #print 'result is', result
     if result is not None:
         #print 'self.queue.get() is ', result 
         file_input_watcher.stop_monitoring()
     #clean up file mess created
     if os.path.isfile(os.path.join(dir, testFile)) is True:
         os.remove(os.path.join(dir, testFile))
     self.assertEqual(result, os.path.join(dir, testFile))
Ejemplo n.º 4
0
 def test_file_add(self):
     self.queue = Queue.Queue(0)
     dir = testcase_settings.INPUTFILES_PATH
     testFile = testcase_settings.TEST_FILE
     file_input_watcher = FileInputWatcher(dir, self.queue)
     if os.path.isfile(os.path.join(dir, testFile)) is True:
         os.remove(os.path.join(dir, testFile))
     #Start a monitoring thread.  It ends on its own.
     file_input_watcher.monitor()
     #now make a file whilst pyinotify thread is running
     sleep(1)
     f = open(os.path.join(dir, testFile), 'w')
     f.close()
     result = self.queue.get(block='true')
     #print 'result is', result
     if result is not None:
         #print 'self.queue.get() is ', result
         file_input_watcher.stop_monitoring()
     #clean up file mess created
     if os.path.isfile(os.path.join(dir, testFile)) is True:
         os.remove(os.path.join(dir, testFile))
     self.assertEqual(result, os.path.join(dir, testFile))