Пример #1
0
    def test_set_expression_in_relation_and_get_set_elements(self):
        rel = rules.RequireRelation(None, "1", "${test} = 2")
        self.assertEquals(rel.get_set_expressions()[0].left.get_ref(), 'test')

        rel = rules.RequireRelation(None, "1", "${test} = 2 and ${t} = 3")
        self.assertEquals(len(rel.get_set_expressions()), 2)
        self.assertEquals(rel.get_set_expressions()[0].left.get_ref(), 'test')
        self.assertEquals(rel.get_set_expressions()[1].left.get_ref(), 't')
Пример #2
0
 def test_set_expression_in_relation(self):
     rel = rules.RequireRelation(None, "1", "${test} = 1")
     c = DictContext({'test': None, 't': None})
     rel.execute(c)
     self.assertEquals(c.data['test'], 1)
     rel = rules.RequireRelation(None, "1", "${test} = 2 and ${t} = 3")
     rel.execute(c)
     self.assertEquals(c.data['test'], 2)
     self.assertEquals(c.data['t'], 3)
Пример #3
0
 def test_set_expression_in_relation_with_ref_concat(self):
     rel = rules.RequireRelation(None, "1",
                                 '${test} = ${s1} + " " + u"bar" + ${s2}')
     c = DictContext({'test': None, 's1': 'test', 's2': 'one'})
     rel.execute(c)
     self.assertEquals(c.data['test'], 'test barone')
Пример #4
0
 def test_set_expression_in_relation_with_string_concat(self):
     rel = rules.RequireRelation(None, "1", '${test} = "foo " + "bar"')
     c = DictContext({'test': None, 't': None})
     rel.execute(c)
     self.assertEquals(c.data['test'], 'foo bar')
Пример #5
0
    def test_set_expression_in_relation_and_get_set_refs(self):
        rel = rules.RequireRelation(None, "1", "${test} = 2")
        self.assertEquals(rel.get_set_refs(), ['test'])

        rel = rules.RequireRelation(None, "1", "${test} = 2 and ${t} = 3")
        self.assertEquals(rel.get_set_refs(), ['test', 't'])
Пример #6
0
 def test_get_expressions_from_relation(self):
     rel = rules.RequireRelation(None, "${foo} == True",
                                 "${test} = 2 and ${aaa} == ${bbb}")
     self.assertEquals(len(rel.get_expressions()), 11)