Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117876600
test-008-sievelib.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
test-008-sievelib.py
View Options
import
sys
import
unittest
sieve_scripts
=
[
# You're average vacation script.
"""
require [ "vacation" ];
if anyof (true) {
vacation :days 1 :subject "Out of Office" "I'm out of the office";
}
"""
,
# 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
):
def
test_001_import_sievelib
(
self
):
from
sievelib.parser
import
Parser
def
test_002_parse_tests
(
self
):
from
sievelib.parser
import
Parser
sieve_parser
=
Parser
(
debug
=
True
)
i
=
0
for
sieve_str
in
sieve_scripts
:
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
)
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Apr 5 2026, 9:08 PM (4 w, 3 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
11/67/3163a11092b1b5c0fb692d2570c2
Default Alt Text
test-008-sievelib.py (1 KB)
Attached To
Mode
rP pykolab
Attached
Detach File
Event Timeline