summaryrefslogtreecommitdiffstats
path: root/tests/unit/test-008-sievelib.py
diff options
context:
space:
mode:
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)