示例#1
0
 def test_limit(self):
     glob = '/[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/[0-9][0-9]'
     paths = [(datetime.datetime(2013, 12, 31, 5) +
               datetime.timedelta(hours=h)).strftime('/%Y/%m/%d/%H')
              for h in xrange(40)]
     self.assertEqual(sorted(_constrain_glob(glob, paths)), [
         '/2013/12/31/[0-2][0-9]',
         '/2014/01/01/[0-2][0-9]',
     ])
     paths.pop(26)
     self.assertEqual(sorted(_constrain_glob(glob, paths, 6)), [
         '/2013/12/31/0[5-9]',
         '/2013/12/31/1[0-9]',
         '/2013/12/31/2[0-3]',
         '/2014/01/01/0[012345689]',
         '/2014/01/01/1[0-9]',
         '/2014/01/01/2[0]',
     ])
     self.assertEqual(sorted(_constrain_glob(glob, paths[:7], 10)), [
         '/2013/12/31/05',
         '/2013/12/31/06',
         '/2013/12/31/07',
         '/2013/12/31/08',
         '/2013/12/31/09',
         '/2013/12/31/10',
         '/2013/12/31/11',
     ])
示例#2
0
 def test_limit(self):
     glob = '/[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/[0-9][0-9]'
     paths = [(datetime.datetime(2013, 12, 31, 5) + datetime.timedelta(hours=h)).strftime('/%Y/%m/%d/%H') for h in range(40)]
     self.assertEqual(sorted(_constrain_glob(glob, paths)), [
         '/2013/12/31/[0-2][0-9]',
         '/2014/01/01/[0-2][0-9]',
     ])
     paths.pop(26)
     self.assertEqual(sorted(_constrain_glob(glob, paths, 6)), [
         '/2013/12/31/0[5-9]',
         '/2013/12/31/1[0-9]',
         '/2013/12/31/2[0-3]',
         '/2014/01/01/0[012345689]',
         '/2014/01/01/1[0-9]',
         '/2014/01/01/2[0]',
     ])
     self.assertEqual(sorted(_constrain_glob(glob, paths[:7], 10)), [
         '/2013/12/31/05',
         '/2013/12/31/06',
         '/2013/12/31/07',
         '/2013/12/31/08',
         '/2013/12/31/09',
         '/2013/12/31/10',
         '/2013/12/31/11',
     ])
示例#3
0
 def test_no_wildcards(self):
     glob = '/2014/01'
     paths = '/2014/01'
     self.assertEqual(_constrain_glob(glob, paths), [
         '/2014/01',
     ])
示例#4
0
 def test_no_wildcards(self):
     glob = '/2014/01'
     paths = '/2014/01'
     self.assertEqual(_constrain_glob(glob, paths), [
         '/2014/01',
     ])