-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
108 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pre-commit | ||
black | ||
pylint | ||
pytest | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +0,0 @@ | ||
"""sievelib.""" | ||
|
||
from pkg_resources import get_distribution, DistributionNotFound | ||
|
||
|
||
try: | ||
__version__ = get_distribution(__name__).version | ||
except DistributionNotFound: | ||
# package is not installed | ||
pass | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -569,6 +569,14 @@ def test_vacationext_with_multiline(self): | |
--foo-- | ||
. | ||
; | ||
""" | ||
) | ||
|
||
def test_vacation_seconds(self): | ||
self.compilation_ok( | ||
""" | ||
require ["vacation", "vacation-seconds"]; | ||
vacation :seconds 10 :addresses ["[email protected]"] "Gone"; | ||
""" | ||
) | ||
|
||
|
@@ -595,7 +603,7 @@ def test_fileinto_create(self): | |
|
||
def test_imap4flags_extension(self): | ||
self.compilation_ok( | ||
b""" | ||
rb""" | ||
require ["fileinto", "imap4flags", "variables"]; | ||
if size :over 1M { | ||
addflag "MyFlags" "Big"; | ||
|
@@ -831,6 +839,14 @@ def test_missing_comma_in_test_list(self): | |
self.compilation_ko( | ||
b""" | ||
if allof(anyof(address "From" "example.com") header "Subject" "Example") { stop; } | ||
""" | ||
) | ||
|
||
def test_vacation_seconds_no_arg(self): | ||
self.compilation_ko( | ||
""" | ||
require ["vacation", "vacation-seconds"]; | ||
vacation :seconds :addresses ["[email protected]"] "Gone"; | ||
""" | ||
) | ||
|
||
|
@@ -1071,5 +1087,79 @@ def test_fileinto_with_copy(self): | |
) | ||
|
||
|
||
class RegexMatchTestCase(SieveTest): | ||
def test_header_regex(self): | ||
self.compilation_ok( | ||
b"""require "regex"; | ||
if header :regex "Subject" "^Test" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
def test_header_regex_no_middle(self): | ||
self.compilation_ko( | ||
b"""require "regex"; | ||
if header "Subject" :regex "^Test" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
def test_envelope_regex(self): | ||
self.compilation_ok( | ||
b"""require ["regex","envelope"]; | ||
if envelope :regex "from" "^test@example\\.org$" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
def test_envelope_regex_no_middle(self): | ||
self.compilation_ko( | ||
b"""require "regex"; | ||
if envelope "from" :regex "^test@example\\.org$" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
def test_address_regex(self): | ||
self.compilation_ok( | ||
b"""require "regex"; | ||
if address :regex "from" "^test@example\\.org$" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
def test_address_regex_no_middle(self): | ||
self.compilation_ko( | ||
b"""require "regex"; | ||
if address "from" :regex "^test@example\\.org$" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
def test_body_raw_regex(self): | ||
self.compilation_ok( | ||
b"""require ["body", "regex"]; | ||
if body :raw :regex "Sample" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
def test_body_content_regex(self): | ||
self.compilation_ok( | ||
b"""require ["body", "regex"]; | ||
if body :content "text" :regex "Sample" { | ||
discard; | ||
} | ||
""" | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |