예제 #1
0
 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")
예제 #2
0
 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)
예제 #3
0
 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")
예제 #4
0
 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')
예제 #5
0
    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())
예제 #6
0
 def testNewVersion(self):
     """
     Test that the new procedure works properly.
     """
     result = Template.runProcedure('newver',
                                    BaseTestCase.dataTestsDirectory())
     self.assertEqual(result, 'v003')
예제 #7
0
 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')
예제 #8
0
 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, '')
예제 #9
0
 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')
예제 #10
0
 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')
예제 #11
0
 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')
예제 #12
0
 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, '')
예제 #13
0
 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')
예제 #14
0
 def testHour(self):
     """
     Test that the hour procedure works properly.
     """
     hour = Template.runProcedure("hour")
     self.assertGreaterEqual(int(hour), 0)
     self.assertLessEqual(int(hour), 23)
예제 #15
0
 def testMinute(self):
     """
     Test that the minute procedure works properly.
     """
     minute = Template.runProcedure("minute")
     self.assertGreaterEqual(int(minute), 0)
     self.assertLessEqual(int(minute), 59)
예제 #16
0
 def testMonth(self):
     """
     Test that the month procedure works properly.
     """
     mm = Template.runProcedure("mm")
     self.assertGreaterEqual(int(mm), 1)
     self.assertLessEqual(int(mm), 12)
예제 #17
0
 def testDay(self):
     """
     Test that the day procedure works properly.
     """
     dd = Template.runProcedure("dd")
     self.assertGreaterEqual(int(dd), 1)
     self.assertLessEqual(int(dd), 31)
예제 #18
0
 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')
예제 #19
0
 def testSecond(self):
     """
     Test that the second procedure works properly.
     """
     second = Template.runProcedure("second")
     self.assertGreaterEqual(int(second), 0)
     self.assertLessEqual(int(second), 59)
예제 #20
0
    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())
예제 #21
0
 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)
예제 #22
0
 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')
예제 #23
0
 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)
예제 #24
0
 def testTmpdir(self):
     """
     Test that the tmpdir procedure works properly.
     """
     result = Template.runProcedure("tmpdir")
     self.assertFalse(os.path.exists(result))
예제 #25
0
 def testSum(self):
     """
     Test that the sum procedure works properly.
     """
     result = Template.runProcedure("sum", 1, 2)
     self.assertEqual(result, "3")
예제 #26
0
 def testMax(self):
     """
     Test that the max procedure works properly.
     """
     result = Template.runProcedure("max", 6, 2)
     self.assertEqual(result, "6")
예제 #27
0
 def testMin(self):
     """
     Test that the min procedure works properly.
     """
     result = Template.runProcedure("min", 6, 2)
     self.assertEqual(result, "2")
예제 #28
0
 def testDiv(self):
     """
     Test that the div procedure works properly.
     """
     result = Template.runProcedure("div", 6, 2)
     self.assertEqual(result, "3")
예제 #29
0
 def testMult(self):
     """
     Test that the mult procedure works properly.
     """
     result = Template.runProcedure("mult", 2, 3)
     self.assertEqual(result, "6")
예제 #30
0
 def testTmp(self):
     """
     Test that the tmp procedure works properly.
     """
     result = Template.runProcedure("tmp")
     self.assertEqual(result, tempfile.gettempdir())