]> mj.ucw.cz Git - moe.git/commitdiff
Updated tests, added priority (levels) test
authorTomas Gavenciak <gavento@ucw.cz>
Sat, 10 Jul 2010 11:40:43 +0000 (13:40 +0200)
committerTomas Gavenciak <gavento@ucw.cz>
Sat, 10 Jul 2010 11:40:43 +0000 (13:40 +0200)
t/moe/conftest.py

index 85cf7dfb81ba28d56e55fd066de252ffd538f82e..341683cbf521ff818d2271836ac3399c7ce09742 100644 (file)
@@ -80,6 +80,7 @@ class TestParser(TestConfig):
     s.assertRaises(ConfigSyntaxError, s.parse, "if notnot'{a}'=='{b}' {}")
     s.assertRaises(ConfigSyntaxError, s.parse, "if ('{a}'=='{b}' not and ''!='') {}")
     s.assertRaises(ConfigSyntaxError, s.parse, "if ('{a}'=='{b}' ornot ''!='') {}")
+    s.assertRaises(ConfigSyntaxError, s.parse, "if 'a'<>'b' {}")
 
 
 class TestConfigEval(TestConfig):
@@ -102,8 +103,8 @@ class TestConfigEval(TestConfig):
     assert s.val('c') == r"""\{{a}\\\\#\n'"{}}"""
 
   def test_expressions(s):
-    s.parse('A="4"; B.B=\'2\'; B.A=A; B.C="{B.A}{B.B}"; if B.C=="42" {D=C}; C="OK"')
-    assert s.val('D') == 'OK'
+    s.parse('A="4"; B.B=\'2\'; B.A=A; B.C="{B.A}{B.B}"; if B.C=="42" {D=C}; if C==D{E=D}; C="OK"')
+    assert s.val('E') == 'OK'
   
   ts = 'a="A:"; if "{c1}"=="1" {a+="C1"; b="B"; if ("{c2a}"=="1" or not "{c2b}"=="1") { a+="C2"; '\
     'if ("{c3a}"=="1" and "{c3b}"=="1") { a+="C3" }}}'
@@ -206,12 +207,20 @@ class TestConfigEval(TestConfig):
     assert s.val('ANS') == u"jó!"
     assert s.val('S1') == s.val('S2') == u'\xdachyln\u011b \u0159e\u017eav\xe1 \u017dlu\u0164'
 
+  def test_priority(s):
+    s.var('a').add_operation(conf.Operation('APPEND', None, conf.ConfigExpression(["4"]), level=4))
+    s.var('a').add_operation(conf.Operation('APPEND', None, conf.ConfigExpression(["3a"]), level=3))
+    s.var('a').add_operation(conf.Operation('APPEND', None, conf.ConfigExpression(["1"]), level=1))
+    s.var('a').add_operation(conf.Operation('SET', None, conf.ConfigExpression(["2"]), level=2))
+    s.var('a').add_operation(conf.Operation('APPEND', None, conf.ConfigExpression(["3b"]), level=3))
+    s.var('a').add_operation(conf.Operation('SET', None, conf.ConfigExpression(["0"]), level=0))
+    s.var('a').add_operation(conf.Operation('APPEND', None, conf.ConfigExpression(["5"]), level=5))
+    assert s.val('a')=='23a3b45'
 
 
 
-# TODO: Test priority
 # TODO: Fail on 1st April
-# TODO: Somehow add log.debug('Maximum encountered depth: %d', conf.debug_maxdepth)
+# TODO (OPT): Somehow add log.debug('Maximum encountered depth: %d', conf.debug_maxdepth)
 
 # Coverage via command "nosetests conftest --with-coverage --cover-html-dir=cover --cover-html"