def testPadding(self): """ Test that the padding procedure works properly. """ padding = Template.runProcedure("pad", 1, 4) self.assertEqual(padding, "0001") padding = Template.runProcedure("pad", 100, 6) self.assertEqual(padding, "000100")
def testYear(self): """ Test that the year template procedures work properly. """ yyyy = Template.runProcedure("yyyy") self.assertGreaterEqual(int(yyyy), 2018) yy = Template.runProcedure("yy") self.assertEqual(yyyy[-2:], yy)
def testRetimePadding(self): """ Test that the retime padding procedure works properly. """ padding = Template.runProcedure("retimepad", 1, 5, 4) self.assertEqual(padding, "0006") padding = Template.runProcedure("retimepad", 100, -99, 6) self.assertEqual(padding, "000001")
def testLatestVersion(self): """ Test that the latest version is found properly. """ result = Template.runProcedure('latestver', BaseTestCase.dataTestsDirectory()) self.assertEqual(result, 'v002') result = Template.runProcedure( 'latestver', os.path.join(BaseTestCase.dataTestsDirectory(), 'glob')) self.assertEqual(result, 'v000')
def testRegistration(self): """ Test that the procedure registration works properly. """ def myDummyTemplate(a, b): return '{}-{}'.format(a, b) with self.assertRaises(TemplateProcedureNotFoundError): Template.runProcedure("dummyRegistration") Template.registerProcedure("dummyRegistration", myDummyTemplate) self.assertIn("dummyRegistration", Template.registeredProcedureNames())
def testNewVersion(self): """ Test that the new procedure works properly. """ result = Template.runProcedure('newver', BaseTestCase.dataTestsDirectory()) self.assertEqual(result, 'v003')
def testLabelVersionCustomFullPattern(self): """ Test that the label procedure works with a custom version using full pattern. """ customPattern = 'ab#####_cd' result = Template.runProcedure('labelver', 5, customPattern) self.assertEqual(result, 'ab00005_cd')
def testVersionEmptyPrefixCustomPattern(self): """ Test that the version prefix procedure works with a custom version without prefix. """ customPattern = '#####d' result = Template.runProcedure('verprefix', '00005d', customPattern) self.assertEqual(result, '')
def testLabelVersionCustomSuffixPattern(self): """ Test that the label procedure works with a custom version pattern with suffix. """ customPattern = '#####b' result = Template.runProcedure('labelver', 5, customPattern) self.assertEqual(result, '00005b')
def testLabelVersionCustomPattern(self): """ Test that the label procedure works with a custom version pattern using only digits. """ customPattern = '#####' result = Template.runProcedure('labelver', 5, customPattern) self.assertEqual(result, '00005')
def testVersionSuffixCustomPattern(self): """ Test that the version suffix procedure works with a custom version. """ customPattern = 'd#####abc' result = Template.runProcedure('versuffix', 'd00005abc', customPattern) self.assertEqual(result, 'abc')
def testVersionEmptySuffixCustomPattern(self): """ Test that the version suffix procedure works with a custom version without suffix. """ customPattern = 'abc#####' result = Template.runProcedure('versuffix', 'abc00005', customPattern) self.assertEqual(result, '')
def testVersionNumberCustomPattern(self): """ Test that the version number procedure works with a custom version. """ customPattern = 'abc#####d' result = Template.runProcedure('vernumber', 'abc00005d', customPattern) self.assertEqual(result, '00005')
def testHour(self): """ Test that the hour procedure works properly. """ hour = Template.runProcedure("hour") self.assertGreaterEqual(int(hour), 0) self.assertLessEqual(int(hour), 23)
def testMinute(self): """ Test that the minute procedure works properly. """ minute = Template.runProcedure("minute") self.assertGreaterEqual(int(minute), 0) self.assertLessEqual(int(minute), 59)
def testMonth(self): """ Test that the month procedure works properly. """ mm = Template.runProcedure("mm") self.assertGreaterEqual(int(mm), 1) self.assertLessEqual(int(mm), 12)
def testDay(self): """ Test that the day procedure works properly. """ dd = Template.runProcedure("dd") self.assertGreaterEqual(int(dd), 1) self.assertLessEqual(int(dd), 31)
def testVersionNumberOnlyDigitsCustomPattern(self): """ Test that the version number procedure works with a custom version that contains only the digits. """ customPattern = '#####' result = Template.runProcedure('vernumber', '00005', customPattern) self.assertEqual(result, '00005')
def testSecond(self): """ Test that the second procedure works properly. """ second = Template.runProcedure("second") self.assertGreaterEqual(int(second), 0) self.assertLessEqual(int(second), 59)
def testEnv(self): """ Test that the env procedure works properly. """ userEnvironment = 'USER' if 'USER' in os.environ else 'USERNAME' result = Template.runProcedure("env", userEnvironment) self.assertEqual(result, getpass.getuser())
def testRFindPath(self): """ Test that the rfind procedure works properly. """ result = Template.runProcedure('rfindpath', 'test.txt', self.__testRFindPath) testPath = os.path.join(BaseTestCase.dataTestsDirectory(), 'test.txt') self.assertEqual(result, testPath)
def testLatestVersionCustomPattern(self): """ Test that the new procedure works with a custom version pattern. """ customPattern = 'v#####b' result = Template.runProcedure('latestver', BaseTestCase.dataTestsDirectory(), customPattern) self.assertEqual(result, 'v00004b')
def testFindPath(self): """ Test that the find procedure works properly. """ result = Template.runProcedure("findpath", 'TestCrawler.py', BaseTestCase.dataTestsDirectory()) testPath = os.path.join(BaseTestCase.dataTestsDirectory(), 'config', 'crawlers', 'TestCrawler.py') self.assertEqual(result, testPath)
def testTmpdir(self): """ Test that the tmpdir procedure works properly. """ result = Template.runProcedure("tmpdir") self.assertFalse(os.path.exists(result))
def testSum(self): """ Test that the sum procedure works properly. """ result = Template.runProcedure("sum", 1, 2) self.assertEqual(result, "3")
def testMax(self): """ Test that the max procedure works properly. """ result = Template.runProcedure("max", 6, 2) self.assertEqual(result, "6")
def testMin(self): """ Test that the min procedure works properly. """ result = Template.runProcedure("min", 6, 2) self.assertEqual(result, "2")
def testDiv(self): """ Test that the div procedure works properly. """ result = Template.runProcedure("div", 6, 2) self.assertEqual(result, "3")
def testMult(self): """ Test that the mult procedure works properly. """ result = Template.runProcedure("mult", 2, 3) self.assertEqual(result, "6")
def testTmp(self): """ Test that the tmp procedure works properly. """ result = Template.runProcedure("tmp") self.assertEqual(result, tempfile.gettempdir())