Ejemplo n.º 1
0
 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")
Ejemplo n.º 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")
Ejemplo n.º 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)
Ejemplo n.º 4
0
 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")
Ejemplo n.º 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())
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 14
0
 def testMax(self):
     """
     Test that the max expression works properly.
     """
     result = ExpressionEvaluator.run("max", 6, 2)
     self.assertEqual(result, "6")
Ejemplo n.º 15
0
 def testSum(self):
     """
     Test that the sum expression works properly.
     """
     result = ExpressionEvaluator.run("sum", 1, 2)
     self.assertEqual(result, "3")
Ejemplo n.º 16
0
 def testDiv(self):
     """
     Test that the div expression works properly.
     """
     result = ExpressionEvaluator.run("div", 6, 2)
     self.assertEqual(result, "3")
Ejemplo n.º 17
0
 def testMin(self):
     """
     Test that the min expression works properly.
     """
     result = ExpressionEvaluator.run("min", 6, 2)
     self.assertEqual(result, "2")
Ejemplo n.º 18
0
 def testUpper(self):
     """
     Test that the upper expression works properly.
     """
     result = ExpressionEvaluator.run("upper", "boop")
     self.assertEqual(result, "BOOP")
Ejemplo n.º 19
0
 def testMult(self):
     """
     Test that the mult expression works properly.
     """
     result = ExpressionEvaluator.run("mult", 2, 3)
     self.assertEqual(result, "6")
Ejemplo n.º 20
0
 def testEnv(self):
     """
     Test that the env expression works properly.
     """
     result = ExpressionEvaluator.run("env", "USERNAME")
     self.assertEqual(result, os.environ.get("USERNAME"))
Ejemplo n.º 21
0
 def testTmpdir(self):
     """
     Test that the tmpdir expression works properly.
     """
     result = ExpressionEvaluator.run("tmpdir")
     self.assertFalse(os.path.exists(result))
Ejemplo n.º 22
0
 def testBasename(self):
     """
     Test that the basename expression works properly.
     """
     result = ExpressionEvaluator.run("basename", self.__path)
     self.assertEqual(result, "example.ext")
Ejemplo n.º 23
0
 def testParentDirname(self):
     """
     Test that the parentdirname expression works properly.
     """
     result = ExpressionEvaluator.run("parentdirname", self.__path)
     self.assertEqual(result, "/test")
Ejemplo n.º 24
0
 def testRemove(self):
     """
     Test that the remove expression works properly.
     """
     result = ExpressionEvaluator.run("remove", "boop", "p")
     self.assertEqual(result, "boo")
Ejemplo n.º 25
0
 def testNewVersion(self):
     """
     Test that the new expression works properly.
     """
     result = ExpressionEvaluator.run("newver", BaseTestCase.dataDirectory())
     self.assertEqual(result, "v003")
Ejemplo n.º 26
0
 def testReplace(self):
     """
     Test that the replace expression works properly.
     """
     result = ExpressionEvaluator.run("replace", "Boop", "o", "e")
     self.assertEqual(result, "Beep")