Ejemplo n.º 1
0
 def test_base_not_first(self):
     ''' The base file isn't treated special and returned first. It's sorted
     based on modtime '''
     with TemporaryDirectory() as tempdir:
         base = os.path.join(tempdir, 'results.log')
         other = base + '.foo'
         touch(base)
         touch(other)
         # base is older, so returned first
         assert v3bw._find_files(base) == [base, other]
         # other is older, so returned first
         touch(other)
         touch(base)
         assert v3bw._find_files(base) == [other, base]
Ejemplo n.º 2
0
 def test_multi(self):
     ''' Multiple files to match, and they are returned in the correct order
     '''
     with TemporaryDirectory() as tempdir:
         # f1 is older, so returned first
         base = os.path.join(tempdir, 'results.log')
         f1 = base + 'f1'
         f2 = base + 'f2'
         touch(f1)
         touch(f2)
         assert v3bw._find_files(base) == [f1, f2]
         # f2 is older, so returned first
         touch(f2)
         touch(f1)
         assert v3bw._find_files(base) == [f2, f1]
Ejemplo n.º 3
0
 def test_recent_enough(self):
     ''' The only file that exists is new enough to be considered '''
     with TemporaryDirectory() as tempdir:
         fname = os.path.join(tempdir, 'foo')
         now = 1000000
         touch(fname, times=(now, now))
         assert v3bw._find_files(fname, min_ts=now - 1) == [fname]
Ejemplo n.º 4
0
 def test_too_old(self):
     ''' The only file that exists is too old to be considered '''
     with TemporaryDirectory() as tempdir:
         fname = os.path.join(tempdir, 'foo')
         now = 1000000
         touch(fname, times=(now, now))
         assert v3bw._find_files(fname, min_ts=now + 1) == []
Ejemplo n.º 5
0
 def test_justbase(self):
     ''' Result file exists, but nothing to glob for, still get list
     containing result file '''
     with TemporaryDirectory() as tempdir:
         base = os.path.join(tempdir, 'results.log')
         touch(base)
         assert v3bw._find_files(base) == [base]
Ejemplo n.º 6
0
 def test_justbase_unrelated_dir(self):
     ''' Result file exists, nothing to glob for, and similarly-named
     directory.  Get just result file. '''
     with TemporaryDirectory() as tempdir:
         base = os.path.join(tempdir, 'results.log')
         touch(base)
         os.mkdir(os.path.join(tempdir, 'results.log.thisisadir'))
         assert v3bw._find_files(base) == [base]
Ejemplo n.º 7
0
 def test_justbase_unrelated(self):
     ''' Result file exists, nothing to glob for, and unrelated file in same
     dir. Get just result file. '''
     with TemporaryDirectory() as tempdir:
         base = os.path.join(tempdir, 'results.log')
         touch(base)
         touch(os.path.join(tempdir, 'unrelated_file'))
         assert v3bw._find_files(base) == [base]
Ejemplo n.º 8
0
 def test_nonexist(self):
     ''' Result file not existing, nor anything to glob for, returns empty
     list '''
     path = '/path/that/does/not/exist'
     assert v3bw._find_files(path) == []