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)
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)
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)
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' ]
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)
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)
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)
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)
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)
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)
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 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' }] }
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)
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 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 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)
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']])