Exemplo n.º 1
0
 def test_invalid_var_format_1(self):
     ctx = Context()
     ctx.addVariable("a", "1")
     try:
         res = ctx.getFormated("${a")
     except:
         pass
     else:
         self.fail("Can't fail if invalid format")
Exemplo n.º 2
0
    def test_parent_context(self):
        rootCtx = Context()
        rootCtx.addVariable("a", "1")

        childCtx = Context()
        childCtx.addVariable("b", "2")

        childCtx.setParentContext(rootCtx)
        self.assertEqual(childCtx.getVariable("a"), "1")
Exemplo n.º 3
0
 def test_add_variable(self):
     ctx = Context()
     ctx.addVariable("currentDir", "1")
     res = ctx.getFormated("a/${currentDir}/b")
     self.assertEqual(res, "a/1/b")
Exemplo n.º 4
0
 def test_update_list_for_step(self):
     ctx = Context()
     ctx.addVariable("a", "a")
     data = {"a": ["${a}"]}
     res = ctx.createStepNode(data)
     self.assertEqual(res["a"][0], "a")
Exemplo n.º 5
0
 def test_add_varible_format(self):
     ctx = Context()
     ctx.addVariable("a", "a")
     ctx.addVariable("b", "${a}/b")
     res = ctx.getFormated("${b}/c")
     self.assertEqual(res, "a/b/c")
Exemplo n.º 6
0
 def test_add_two_variable(self):
     ctx = Context()
     ctx.addVariable("a", "linux")
     ctx.addVariable("b", "release")
     res = ctx.getFormated("${a}/${b}")
     self.assertEqual(res, "linux/release")
Exemplo n.º 7
0
 def test_readd_variable(self):
     ctx = Context()
     ctx.addVariable("currentDir", "1")
     ctx.addVariable("currentDir", "2")
     res = ctx.getFormated("${currentDir}")
     self.assertEqual(res, "2")