summaryrefslogtreecommitdiffstats
path: root/tests/unit/test-008-sievelib.py
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-12-04 15:34:05 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-12-04 15:34:55 +0000
commit5cce5af0cfed978b8eb4560b761123217c854878 (patch)
treed8b6bf99d0d6f1c2665a58165d71130980c281ce /tests/unit/test-008-sievelib.py
parent9e4126d0d79c9f37aace2e28b24c8321e95a5ca5 (diff)
downloadpykolab-5cce5af0cfed978b8eb4560b761123217c854878.tar.gz
Add a few additional scripts to test
Diffstat (limited to 'tests/unit/test-008-sievelib.py')
-rw-r--r--tests/unit/test-008-sievelib.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/unit/test-008-sievelib.py b/tests/unit/test-008-sievelib.py
index a6328dc..cd4eb3b 100644
--- a/tests/unit/test-008-sievelib.py
+++ b/tests/unit/test-008-sievelib.py
@@ -2,7 +2,9 @@ import sys
import unittest
sieve_scripts = [
- """
+
+# You're average vacation script.
+"""
require [ "vacation" ];
if anyof (true) {
@@ -10,6 +12,30 @@ if anyof (true) {
}
""",
+# A non-any/allof if (control) header (test) structure
+"""
+require ["fileinto"];
+
+if header :contains "X-Spam-Flag" "YES" {
+ fileinto "Spam";
+ stop;
+}
+""",
+
+# The same, all on the same line
+"""
+require ["fileinto"];
+
+if header :contains "X-Spam-Flag" "YES" { fileinto "Spam"; stop; }
+""",
+
+# A little more of a complex list of tests
+"""
+require ["fileinto"];
+
+if allof (header :contains "X-Mailer" "OTRS", header :contains "X-Powered-By" "OTRS", header :contains "Organization" "Example, Inc.") { fileinto "OTRS"; stop; }
+""",
+
]
class TestSievelib(unittest.TestCase):
@@ -17,7 +43,7 @@ class TestSievelib(unittest.TestCase):
def test_001_import_sievelib(self):
from sievelib.parser import Parser
- def test_002_parse_vacation(self):
+ def test_002_parse_tests(self):
from sievelib.parser import Parser
sieve_parser = Parser(debug=True)
@@ -26,4 +52,5 @@ class TestSievelib(unittest.TestCase):
i += 1
result = sieve_parser.parse(sieve_str)
if not result:
+ print "Sieve line: %r" % (sieve_parser.lexer.text.split('\n')[(sieve_parser.lexer.text[:sieve_parser.lexer.pos].count('\n'))])
raise Exception, "Failed parsing Sieve script #%d: %s" % (i, sieve_parser.error)