def testRetimePadding(self):
     """
     Test that the retime padding expression works properly.
     """
     padding = ExpressionEvaluator.run("retimepad", 1, 5, 4)
     self.assertEqual(padding, "0006")
     padding = ExpressionEvaluator.run("retimepad", 100, -99, 6)
     self.assertEqual(padding, "000001")
Exemple #2
0
 def testLatestVersion(self):
     """
     Test that the latest version is found properly.
     """
     result = ExpressionEvaluator.run("latestver", BaseTestCase.dataDirectory())
     self.assertEqual(result, "v002")
     result = ExpressionEvaluator.run("latestver", os.path.join(BaseTestCase.dataDirectory(), "glob"))
     self.assertEqual(result, "v000")
Exemple #3
0
 def testYear(self):
     """
     Test that the year expressions work properly.
     """
     yyyy = ExpressionEvaluator.run("yyyy")
     self.assertGreaterEqual(int(yyyy), 2018)
     yy = ExpressionEvaluator.run("yy")
     self.assertEqual(yyyy[-2:], yy)
 def testPadding(self):
     """
     Test that the padding expression works properly.
     """
     padding = ExpressionEvaluator.run("pad", 1, 4)
     self.assertEqual(padding, "0001")
     padding = ExpressionEvaluator.run("pad", 100, 6)
     self.assertEqual(padding, "000100")
Exemple #5
0
    def testRegistration(self):
        """
        Test that the expression registration works properly.
        """
        def myDummyExpression(a, b):
            return '{}-{}'.format(a, b)

        self.assertRaises(ExpressionNotFoundError, ExpressionEvaluator.run,
                          "dummy")
        ExpressionEvaluator.register("dummy", myDummyExpression)
        self.assertIn("dummy", ExpressionEvaluator.registeredNames())
Exemple #6
0
 def testMonth(self):
     """
     Test that the month expression works properly.
     """
     mm = ExpressionEvaluator.run("mm")
     self.assertGreaterEqual(int(mm), 1)
     self.assertLessEqual(int(mm), 12)
Exemple #7
0
 def testMinute(self):
     """
     Test that the minute expression works properly.
     """
     minute = ExpressionEvaluator.run("minute")
     self.assertGreaterEqual(int(minute), 0)
     self.assertLessEqual(int(minute), 59)
Exemple #8
0
 def testSecond(self):
     """
     Test that the second expression works properly.
     """
     second = ExpressionEvaluator.run("second")
     self.assertGreaterEqual(int(second), 0)
     self.assertLessEqual(int(second), 59)
Exemple #9
0
 def testParseRun(self):
     """
     Test that running an expression through string parsing works.
     """
     result = ExpressionEvaluator.parseRun("dirname {}".format(self.__path))
     self.assertEqual(result, "/test/path")
     self.assertRaises(AssertionError, ExpressionEvaluator.parseRun, True)
Exemple #10
0
 def testDay(self):
     """
     Test that the day expression works properly.
     """
     dd = ExpressionEvaluator.run("dd")
     self.assertGreaterEqual(int(dd), 1)
     self.assertLessEqual(int(dd), 31)
Exemple #11
0
 def testHour(self):
     """
     Test that the hour expression works properly.
     """
     hour = ExpressionEvaluator.run("hour")
     self.assertGreaterEqual(int(hour), 0)
     self.assertLessEqual(int(hour), 23)
Exemple #12
0
 def testRFindPath(self):
     """
     Test that the rfind expression works properly.
     """
     result = ExpressionEvaluator.run('rfindpath', 'test.txt',
                                      self.__testRFindPath)
     testPath = os.path.join(BaseTestCase.dataDirectory(), 'test.txt')
     self.assertEqual(result, testPath)
Exemple #13
0
 def testFindPath(self):
     """
     Test that the find expression works properly.
     """
     result = ExpressionEvaluator.run("findpath", 'TestCrawler.py',
                                      BaseTestCase.dataDirectory())
     testPath = os.path.join(BaseTestCase.dataDirectory(), 'config',
                             'crawlers', 'TestCrawler.py')
     self.assertEqual(result, testPath)
Exemple #14
0
 def testMax(self):
     """
     Test that the max expression works properly.
     """
     result = ExpressionEvaluator.run("max", 6, 2)
     self.assertEqual(result, "6")
Exemple #15
0
 def testSum(self):
     """
     Test that the sum expression works properly.
     """
     result = ExpressionEvaluator.run("sum", 1, 2)
     self.assertEqual(result, "3")
Exemple #16
0
 def testDiv(self):
     """
     Test that the div expression works properly.
     """
     result = ExpressionEvaluator.run("div", 6, 2)
     self.assertEqual(result, "3")
Exemple #17
0
 def testMin(self):
     """
     Test that the min expression works properly.
     """
     result = ExpressionEvaluator.run("min", 6, 2)
     self.assertEqual(result, "2")
Exemple #18
0
 def testUpper(self):
     """
     Test that the upper expression works properly.
     """
     result = ExpressionEvaluator.run("upper", "boop")
     self.assertEqual(result, "BOOP")
Exemple #19
0
 def testMult(self):
     """
     Test that the mult expression works properly.
     """
     result = ExpressionEvaluator.run("mult", 2, 3)
     self.assertEqual(result, "6")
Exemple #20
0
 def testEnv(self):
     """
     Test that the env expression works properly.
     """
     result = ExpressionEvaluator.run("env", "USERNAME")
     self.assertEqual(result, os.environ.get("USERNAME"))
Exemple #21
0
 def testTmpdir(self):
     """
     Test that the tmpdir expression works properly.
     """
     result = ExpressionEvaluator.run("tmpdir")
     self.assertFalse(os.path.exists(result))
Exemple #22
0
 def testBasename(self):
     """
     Test that the basename expression works properly.
     """
     result = ExpressionEvaluator.run("basename", self.__path)
     self.assertEqual(result, "example.ext")
Exemple #23
0
 def testParentDirname(self):
     """
     Test that the parentdirname expression works properly.
     """
     result = ExpressionEvaluator.run("parentdirname", self.__path)
     self.assertEqual(result, "/test")
Exemple #24
0
 def testRemove(self):
     """
     Test that the remove expression works properly.
     """
     result = ExpressionEvaluator.run("remove", "boop", "p")
     self.assertEqual(result, "boo")
Exemple #25
0
 def testNewVersion(self):
     """
     Test that the new expression works properly.
     """
     result = ExpressionEvaluator.run("newver", BaseTestCase.dataDirectory())
     self.assertEqual(result, "v003")
Exemple #26
0
 def testReplace(self):
     """
     Test that the replace expression works properly.
     """
     result = ExpressionEvaluator.run("replace", "Boop", "o", "e")
     self.assertEqual(result, "Beep")