示例#1
0
 def test_empty(self, fire_event, dirpath):
     '''
     Verify that empty is true for a queue with no items
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     ret = fq.empty()
     shutil.rmtree(dirpath)
     assert ret == True
示例#2
0
 def test_dirs(self, dirpath):
     '''
     Verify that dirs returns the queues
     '''
     fq = filequeue.FileQueue(root_dir=dirpath, queue='lunch')
     names = fq.dirs()
     shutil.rmtree(dirpath)
     assert 'lunch' == names[0]
示例#3
0
 def test_default_queue(self, dirpath):
     '''
     Verify that the default queue exists
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     queue = os.path.isdir("{}/default".format(dirpath))
     shutil.rmtree(dirpath)
     assert queue == True
示例#4
0
 def test_named_queue(self, dirpath):
     '''
     Verify that the 'lunch' queue exists
     '''
     fq = filequeue.FileQueue(root_dir=dirpath, queue='lunch')
     queue = os.path.isdir("{}/lunch".format(dirpath))
     shutil.rmtree(dirpath)
     assert queue == True
示例#5
0
 def test_check_fails(self, fire_event, dirpath):
     '''
     Verify that check fails
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     checked = fq.check("blue")
     shutil.rmtree(dirpath)
     assert checked == False
示例#6
0
 def test_vacate(self, fire_event, dirpath):
     '''
     Verify that vacate works
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     ret = fq.vacate('red')
     shutil.rmtree(dirpath)
     assert ret == True
示例#7
0
 def test_empty_fails(self, fire_event, dirpath):
     '''
     Verify that empty is false for a queue with any items
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     ret = fq.empty()
     shutil.rmtree(dirpath)
     assert ret == False
示例#8
0
 def test_ls(self, fire_event, dirpath):
     '''
     Verify that ls returns filenames
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     touched = fq.touch("blue")
     files = fq.ls()
     shutil.rmtree(dirpath)
     assert files == ['blue', 'red']
示例#9
0
 def test_touch(self, fire_event):
     '''
     Verify that touch creates a file
     '''
     dirpath = tempfile.mkdtemp()
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     exists = os.path.isfile("{}/default/red".format(dirpath))
     shutil.rmtree(dirpath)
     assert touched and exists
示例#10
0
 def test_vacate_fails(self, fire_event, dirpath):
     '''
     Verify that vacate returns false for any items in queue
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     touched = fq.touch("blue")
     ret = fq.vacate('red')
     shutil.rmtree(dirpath)
     assert ret == None
示例#11
0
 def test_remove(self, fire_event, dirpath):
     '''
     Verify that remove works
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     touched = fq.touch("blue")
     ret = fq.remove('red')
     files = fq.ls()
     shutil.rmtree(dirpath)
     assert ret and files == ['blue']
示例#12
0
 def test_items(self, fire_event, dirpath):
     '''
     Verify that items returns filenames in time order
     '''
     fq = filequeue.FileQueue(root_dir=dirpath)
     touched = fq.touch("red")
     time.sleep(0.1)
     touched = fq.touch("blue")
     time.sleep(0.1)
     touched = fq.touch("red")
     files = fq.items()
     shutil.rmtree(dirpath)
     assert files == ['blue', 'red']