コード例 #1
0
 def testKnownOutputForReversedOrder(self):
     ''' test known output for reverse order data '''
     fsc = FileSequenceChecker()
     output = fsc.processdir(self.dirs['reverse'])
     #printmissing(output)
     #printmissing(self.known_output_for_reverse_order)
     self.assertEquals(output, self.known_output_for_reverse_order)
コード例 #2
0
 def testKnownOutputForMixedOrder(self):
     ''' test known output for mixed order data '''
     fsc = FileSequenceChecker()
     output = fsc.processdir(self.dirs['mixed'])
     #printmissing(output)
     #printmissing(self.known_output_for_mixed_order)
     self.assertEquals(output, self.known_output_for_mixed_order)
コード例 #3
0
 def testKnownOutputForNothingMissing(self):
     ''' test known output for dir with no missing files '''
     fsc = FileSequenceChecker()
     output = fsc.processdir(self.dirs['nothing'])
     #printmissing(output)
     #printmissing(self.known_output_for_nothing_missing)
     self.assertEquals(output, self.known_output_for_nothing_missing)
コード例 #4
0
 def setUp(self):
     self.fsc1 = FileSequenceChecker()
     self.fsc2 = FileSequenceChecker(10, 20, True)
     self.spat1 = ur'^(?P<filename>\w+?)(?P<seqnum>)(?!\W+)$'
     self.spat2 = ur'^.*?(?P<seqnum>.*?)(?P<filename>\w+?).*?$'
     self.spat1template = ur"%(filename)s%(seqnum)s"
     self.spat2template = ur"%(seqnum)s%(filename)s"
     self.badspat1 = ur'.*$'
     self.badspat2 = r''
     self.filenames = [
         u'1 Name20.png',
         u'01 Name20.png',
         u'01-Name20.png',
         u'01Name20.png',
         u'01Name-20.png',
         u'01Name-20',
         u'01Name',
         u'Name20.01.png',
         u'Name20.01.part01',
         u'Name20.01.001',
         u'Name.01.001',
         u'Name.01001',
         u'-Name.01001',
         u'-Name.01001.png',
         u'-Name001.png',
         u'-N0name001-png'
     ]
コード例 #5
0
class TestFileSequenceCheckerFileExcludePattern(unittest.TestCase):
    ''' text cases for the file excludes list used (internally) in preparedircontents(). '''

    def setUp(self):
        self.fsc = FileSequenceChecker()
        self.result = {
            DIRS['fileexcludes']: 
            [{
                'fileext': u'.png',
                'filename': u'Name20.',
                'filename2': u'',
                'order': 'normal',
                'seqnum': u'01'
            }, 
            {
                'fileext': u'.png',
                'filename': u'Name20.',
                'filename2': u'',
                'order': 'normal',
                'seqnum': u'06'
            }]
        }
    
    def testFileExcludes(self):
        ''' test if fileexcludes are excluded from the prepared dir contents. '''
        self.fsc.setfileexcludes(['ExcludeMe']) # extends self.fsc.fileexcludes
        self.fsc._prepare_dir_contents(DIRS['fileexcludes'])
        self.assertEqual(self.fsc._dircontents, self.result)
コード例 #6
0
 def testRestrictedOutputForReversedOrder(self):
     ''' test range restricted known output for reverse order data '''
     fsc = FileSequenceChecker(start=0, end=10)
     output = fsc.processdir(self.dirs['reverse'])
     #printmissing(output)
     #printmissing(self.known_output_for_reverse_order)
     self.assertEquals(output, self.known_restricted_output_for_reverse_order)
コード例 #7
0
 def testKnownOutputForNormalOrder(self):
     ''' test known output for normal order data '''
     fsc = FileSequenceChecker()
     output = fsc.processdir(self.dirs['normal'])
     #printmissing(output)
     #printmissing(self.known_output_for_normal_order)
     self.assertEquals(output, self.known_output_for_normal_order)
コード例 #8
0
 def testVirtualAttributes(self):
     ''' test attributes superimposed by getattr ''' 
     fsc = FileSequenceChecker()
     self.assertFalse(fsc, 'fsc should equal false because len(fsc) returns 0 at this point')
     fsc.processdir(self.dirs['reverse'])
     self.assertTrue(fsc, 'fsc should now equal True because len(fsc) will return != 0 at this point')
     self.assertEquals(fsc.totalfiles, 9)
     self.assertEquals(fsc.totaldirs, 1)
     self.assertEquals(len(fsc[self.dirs['reverse']]), fsc.totalfiles)
コード例 #9
0
class TestFileSequenceCheckerSplitPattern(unittest.TestCase):
    ''' test cases for the split pattern '''
    
    def setUp(self):
        self.fsc1 = FileSequenceChecker()
        self.fsc2 = FileSequenceChecker(10, 20, True)
        self.spat1 = ur'^(?P<filename>\w+?)(?P<seqnum>)(?!\W+)$'
        self.spat2 = ur'^.*?(?P<seqnum>.*?)(?P<filename>\w+?).*?$'
        self.spat1template = ur"%(filename)s%(seqnum)s"
        self.spat2template = ur"%(seqnum)s%(filename)s"
        self.badspat1 = ur'.*$'
        self.badspat2 = r''
        self.filenames = [
            u'1 Name20.png',
            u'01 Name20.png',
            u'01-Name20.png',
            u'01Name20.png',
            u'01Name-20.png',
            u'01Name-20',
            u'01Name',
            u'Name20.01.png',
            u'Name20.01.part01',
            u'Name20.01.001',
            u'Name.01.001',
            u'Name.01001',
            u'-Name.01001',
            u'-Name.01001.png',
            u'-Name001.png',
            u'-N0name001-png'
        ]
        
    def testSetsplitpatternWithNormalInput(self): #IGNORE:C0103
        ''' test changing the split pattern after creation with non-bogus input '''
        self.fsc1.setsplitpattern(self.spat1, self.spat1template)
        self.assertEquals(self.fsc1._splitpat, self.spat1)
        self.fsc2.setsplitpattern(self.spat2, self.spat2template)
        self.assertEqual(self.fsc2._splitpat, self.spat2)
        
    def testReset(self):
        ''' test passing None to setsplitpat in order to reset its to the default state'''
        fsc = FileSequenceChecker()
        fsc.setsplitpattern(self.spat1, self.spat1template)
        fsc.setsplitpattern(None)
        self.assertEqual(fsc.SPLITPAT, fsc._splitpat, 'fsc.splitpat should be reset to FileSequenceChecker.SPLITPAT when fsc.setsplitpattern is called with None as arg')
        
    def testSetsplitpatternWithWrongInput(self): #IGNORE:C0103
        ''' test changing the split pattern after creation with non-bogus but wrong input '''
        self.assertRaises(ValueError, self.fsc1.setsplitpattern, self.badspat1, self.spat1template)
        self.assertRaises(ValueError, self.fsc1.setsplitpattern, self.badspat2, self.spat2template)
        self.assertRaises(ValueError, self.fsc1.setsplitpattern, self.badspat1)
        
    def testDefaultSplitPatternMatches(self):
        ''' test that the default split patterns actually match what they should '''
        for name in self.filenames:
            _fsc = FileSequenceChecker()
            result = _fsc.splitfilename(name)
            self.assertIsNotNone(result)
コード例 #10
0
class TestFileSequenceCheckerExcludePattern(unittest.TestCase):
    ''' test cases for the exclude pattern facility. '''
    
    def setUp(self):
        self.fsc = FileSequenceChecker()
        self.result = {
            DIRS['reverse']: 
            [{
              'fileext': u'.png', 
              'seqnum': u'12', 
              'order': 'reverse', 
              'filename2': u'v', 
              'filename': u'_Write'
            }, {
              'fileext': u'.png', 
              'seqnum': u'15', 
              'order': 'reverse', 
              'filename2': u'v', 
              'filename': u'_Write'
            }]
        }
        
    def testExcludePatternMatches(self):
        ''' test setexcludepattern() '''
        self.fsc.setexcludepattern(ur'Write30')
        self.fsc._prepare_dir_contents(DIRS['reverse'])
        self.assertEqual(self.fsc._dircontents, self.result)
        # now set exclude pattern to something else 
        # and ensure we do not match our expected result
        self.fsc.setexcludepattern(ur'Write60')
        self.fsc._prepare_dir_contents(DIRS['reverse'])
        self.assertNotEqual(self.fsc._dircontents, self.result)
コード例 #11
0
 def setUp(self):
     self.fsc = FileSequenceChecker()
     self.result = {
         DIRS['reverse']: 
         [{
           'fileext': u'.png', 
           'seqnum': u'12', 
           'order': 'reverse', 
           'filename2': u'v', 
           'filename': u'_Write'
         }, {
           'fileext': u'.png', 
           'seqnum': u'15', 
           'order': 'reverse', 
           'filename2': u'v', 
           'filename': u'_Write'
         }]
     }
コード例 #12
0
 def setUp(self):
     self.fsc = FileSequenceChecker()
     self.result = {
         DIRS['fileexcludes']: 
         [{
             'fileext': u'.png',
             'filename': u'Name20.',
             'filename2': u'',
             'order': 'normal',
             'seqnum': u'01'
         }, 
         {
             'fileext': u'.png',
             'filename': u'Name20.',
             'filename2': u'',
             'order': 'normal',
             'seqnum': u'06'
         }]
     }
コード例 #13
0
class TestFileSequenceCheckerIncludePattern(unittest.TestCase):
    ''' test cases for the include pattern facility '''

    def setUp(self):
        self.fsc = FileSequenceChecker()
        self.result = {
            DIRS['normal']:
            [{
              'fileext': u'.bmp', 
              'seqnum': u'002', 
              'order': 'normal', 
              'filename2': u'', 
              'filename': u'line.'
            }, {
              'fileext': u'.bmp', 
              'seqnum': u'003', 
              'order': 'normal', 
              'filename2': u'', 
              'filename': u'line.'
            }, {
              'fileext': u'.bmp', 
              'seqnum': u'010', 
              'order': 'normal', 
              'filename2': u'', 
              'filename': u'line.'
            }]
        }
    
    def testIncludePatternMatches(self):
        ''' test setincludepattern() '''
        self.fsc.setincludepattern(ur'line')
        self.fsc._prepare_dir_contents(DIRS['normal'])
        self.assertEqual(self.fsc._dircontents, self.result)
        # now set include pattern to something else 
        # and ensure we do not match our expected result
        self.fsc.setincludepattern(ur'x')
        self.fsc._prepare_dir_contents(DIRS['normal'])
        self.assertNotEqual(self.fsc._dircontents, self.result)      
コード例 #14
0
 def setUp(self):
     self.fsc = FileSequenceChecker()
     self.result = {
         DIRS['normal']:
         [{
           'fileext': u'.bmp', 
           'seqnum': u'002', 
           'order': 'normal', 
           'filename2': u'', 
           'filename': u'line.'
         }, {
           'fileext': u'.bmp', 
           'seqnum': u'003', 
           'order': 'normal', 
           'filename2': u'', 
           'filename': u'line.'
         }, {
           'fileext': u'.bmp', 
           'seqnum': u'010', 
           'order': 'normal', 
           'filename2': u'', 
           'filename': u'line.'
         }]
     }
コード例 #15
0
 def testReset(self):
     ''' test passing None to setsplitpat in order to reset its to the default state'''
     fsc = FileSequenceChecker()
     fsc.setsplitpattern(self.spat1, self.spat1template)
     fsc.setsplitpattern(None)
     self.assertEqual(fsc.SPLITPAT, fsc._splitpat, 'fsc.splitpat should be reset to FileSequenceChecker.SPLITPAT when fsc.setsplitpattern is called with None as arg')
コード例 #16
0
 def testDefaultSplitPatternMatches(self):
     ''' test that the default split patterns actually match what they should '''
     for name in self.filenames:
         _fsc = FileSequenceChecker()
         result = _fsc.splitfilename(name)
         self.assertIsNotNone(result)
コード例 #17
0
 def testGetitem(self):
     ''' test __getitem__ based notation for the missing results '''
     fsc = FileSequenceChecker(recursive=True)
     self.assertIsNone(fsc[self.dirs['mixed']], "should be None when processdir wasn't run yet.")
     fsc.processdir(self.dirs['mixed'])
     self.assertIsNotNone(fsc[self.dirs['mixed']])