This repository has been archived by the owner on Oct 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve and test LookupPolicy fix bytestring for py3
- Loading branch information
Showing
5 changed files
with
81 additions
and
11 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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
from mox3.mox import MoxTestBase, IsA | ||
|
||
from slimta.envelope import Envelope | ||
from slimta.lookup.policy import LookupPolicy | ||
from slimta.lookup.drivers.dict import DictLookup | ||
|
||
|
||
class TestDictLookup(MoxTestBase): | ||
|
||
def setUp(self): | ||
super(TestDictLookup, self).setUp() | ||
self.data = {} | ||
self.drv = DictLookup(self.data, '{address}') | ||
self.policy = LookupPolicy(self.drv, True, True) | ||
|
||
def test_verp(self): | ||
self.data['sender@example.com'] = {'verp': 'verp.com'} | ||
self.data['rcpt2@example.com'] = {'verp': 'verp.com'} | ||
env = Envelope('sender@example.com', ['rcpt1@example.com', 'rcpt2@example.com']) | ||
self.policy.apply(env) | ||
self.assertEquals('sender=example.com@verp.com', env.sender) | ||
self.assertEquals(['rcpt1@example.com', 'rcpt2=example.com@verp.com'], env.recipients) | ||
|
||
def test_alias(self): | ||
self.data['sender@example.com'] = {'alias': 'sender@other.com'} | ||
self.data['rcpt2@example.com'] = {'alias': 'other.com'} | ||
env = Envelope('sender@example.com', ['rcpt1@example.com', 'rcpt2@example.com']) | ||
self.policy.apply(env) | ||
self.assertEquals('sender@other.com', env.sender) | ||
self.assertEquals(['rcpt1@example.com', 'rcpt2@other.com'], env.recipients) | ||
|
||
def test_add_headers(self): | ||
self.data['sender@example.com'] = {'add_headers': '{"X-Test-A": "one"}'} | ||
self.data['rcpt2@example.com'] = {'add_headers': '{"X-Test-B": "two"}'} | ||
env = Envelope('sender@example.com', ['rcpt1@example.com', 'rcpt2@example.com']) | ||
env.parse(b"""\n\n""") | ||
self.policy.apply(env) | ||
self.assertEquals('one', env.headers['x-test-a']) | ||
self.assertEquals('two', env.headers['x-test-b']) | ||
|
||
# vim:et:fdm=marker:sts=4:sw=4:ts=4:tw=0 |