本文整理汇总了Python中slimta.envelope.Envelope类的典型用法代码示例。如果您正苦于以下问题:Python Envelope类的具体用法?Python Envelope怎么用?Python Envelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Envelope类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_add_message_id_header_existing
def test_add_message_id_header_existing(self):
env = Envelope()
env.parse('Message-Id: testing\r\n')
amih = AddMessageIdHeader()
self.assertEqual('testing', env.headers['Message-Id'])
amih.apply(env)
self.assertEqual('testing', env.headers['Message-Id'])
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_policy_headers.py
示例2: test_recipientsplit_apply
def test_recipientsplit_apply(self):
env = Envelope('[email protected]', ['[email protected]',
'[email protected]'])
env.parse(b"""\
From: [email protected]
To: [email protected]
To: [email protected]
test test\r
""")
policy = RecipientSplit()
env1, env2 = policy.apply(env)
self.assertEqual('[email protected]', env1.sender)
self.assertEqual(['[email protected]'], env1.recipients)
self.assertEqual('[email protected]', env1.headers['from'])
self.assertEqual(['[email protected]', '[email protected]'],
env1.headers.get_all('To'))
self.assertEqual(b'test test\r\n', env1.message)
self.assertEqual('[email protected]', env2.sender)
self.assertEqual(['[email protected]'], env2.recipients)
self.assertEqual('[email protected]', env2.headers['from'])
self.assertEqual(['[email protected]', '[email protected]'],
env2.headers.get_all('To'))
self.assertEqual(b'test test\r\n', env2.message)
开发者ID:slimta,项目名称:python-slimta,代码行数:26,代码来源:test_slimta_policy_split.py
示例3: test_add_date_header_existing
def test_add_date_header_existing(self):
env = Envelope()
env.parse('Date: testing\r\n')
adh = AddDateHeader()
self.assertEqual('testing', env.headers['Date'])
adh.apply(env)
self.assertEqual('testing', env.headers['Date'])
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_policy_headers.py
示例4: test_parse_nonascii_headers
def test_parse_nonascii_headers(self):
env = Envelope()
env.parse(b'Subject: \xc3\xa9\xc3\xa9\n')
try:
self.assertEqual(b'\xc3\xa9\xc3\xa9', env.headers['subject'].encode())
except UnicodeDecodeError:
self.assertEqual(b'\xc3\xa9\xc3\xa9', env.headers['subject'])
开发者ID:madhugb,项目名称:python-slimta,代码行数:7,代码来源:test_slimta_envelope.py
示例5: test_attempt
def test_attempt(self):
self.mox.StubOutWithMock(subprocess, 'Popen')
env = Envelope('[email protected]', ['[email protected]', '[email protected]', '[email protected]', '[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
self._mock_popen('[email protected]', 0, '')
self._mock_popen('[email protected]', 1337, 'transient')
self._mock_popen('[email protected]', 1337, '5.0.0 permanent')
subprocess.Popen(['relaytest', '-f', '[email protected]', '[email protected]'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).AndRaise(Timeout)
self.mox.ReplayAll()
m = PipeRelay(['relaytest', '-f', '{sender}', '{recipient}'])
results = m.attempt(env, 0)
self.assertEqual(4, len(results))
self.assertEqual(None, results['[email protected]'])
self.assertIsInstance(results['[email protected]'], TransientRelayError)
self.assertEqual('transient', str(results['[email protected]']))
self.assertEqual('450', results['[email protected]'].reply.code)
self.assertIsInstance(results['[email protected]'], PermanentRelayError)
self.assertEqual('5.0.0 permanent', str(results['[email protected]']))
self.assertEqual('550', results['[email protected]'].reply.code)
self.assertIsInstance(results['[email protected]'], TransientRelayError)
self.assertEqual('Delivery timed out', str(results['[email protected]']))
self.assertEqual('450', results['[email protected]'].reply.code)
开发者ID:slimta,项目名称:python-slimta,代码行数:25,代码来源:test_slimta_relay_pipe.py
示例6: test_add_headers
def test_add_headers(self):
self.data['[email protected]'] = {'add_headers': '{"X-Test-A": "one"}'}
self.data['[email protected]'] = {'add_headers': '{"X-Test-B": "two"}'}
env = Envelope('[email protected]', ['[email protected]', '[email protected]'])
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'])
开发者ID:slimta,项目名称:python-slimta-lookup,代码行数:8,代码来源:test_slimta_lookup_policy.py
示例7: test_add_date_header
def test_add_date_header(self):
env = Envelope()
env.parse('')
env.timestamp = 1234567890
adh = AddDateHeader()
self.assertEqual(None, env.headers['Date'])
adh.apply(env)
self.assertTrue(env.headers['Date'])
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:8,代码来源:test_slimta_policy_headers.py
示例8: test_encode_7bit
def test_encode_7bit(self):
headers = Message()
headers['From'] = '[email protected]'
headers['To'] = '[email protected]'
body = bytes(bytearray(range(129, 256)))
env = Envelope(headers=headers, message=body)
with self.assertRaises(UnicodeError):
env.encode_7bit()
开发者ID:madhugb,项目名称:python-slimta,代码行数:8,代码来源:test_slimta_envelope.py
示例9: test_add_date_header_existing
def test_add_date_header_existing(self):
env = Envelope()
epoch = 'Thu, 01 Jan 1970 00:00:00 -0000'
env.parse(b'Date: '+epoch.encode()+b'\r\n')
adh = AddDateHeader()
self.assertEqual(epoch, env.headers['Date'])
adh.apply(env)
self.assertEqual(epoch, env.headers['Date'])
开发者ID:madhugb,项目名称:python-slimta,代码行数:8,代码来源:test_slimta_policy_headers.py
示例10: _get_envelope
def _get_envelope(self, environ):
sender = self._get_sender(environ)
recipients = self._get_recipients(environ)
env = Envelope(sender, recipients)
content_length = int(environ.get('CONTENT_LENGTH', 0))
data = environ['wsgi.input'].read(content_length)
env.parse(data)
return env
开发者ID:sk1p,项目名称:python-slimta,代码行数:9,代码来源:wsgi.py
示例11: test_add_message_id_header
def test_add_message_id_header(self):
env = Envelope()
env.parse('')
env.timestamp = 1234567890
amih = AddMessageIdHeader('example.com')
self.assertEqual(None, env.headers['Message-Id'])
amih.apply(env)
pattern = r'^<[0-9a-fA-F]{32}\[email protected]>$'
self.assertRegexpMatches(env.headers['Message-Id'], pattern)
开发者ID:RoboticCheese,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_policy_headers.py
示例12: test_parse_onlyheaders
def test_parse_onlyheaders(self):
env = Envelope()
env.parse("""\
From: [email protected]
Subject: important things
""")
assert_equal('[email protected]', env.headers['from'])
assert_equal('important things', env.headers['subject'])
assert_equal('', env.message)
开发者ID:drewlander,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_envelope.py
示例13: test_parse_onlyheaders
def test_parse_onlyheaders(self):
env = Envelope()
env.parse(b"""\
From: [email protected]
Subject: important things
""".replace(b'\n', b'\r\n'))
self.assertEqual('[email protected]', env.headers['from'])
self.assertEqual('important things', env.headers['subject'])
self.assertEqual(b'', env.message)
开发者ID:madhugb,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_envelope.py
示例14: test_apply
def test_apply(self):
env = Envelope()
env.parse(b"""X-Spam-Status: NO\r\n\r\n""")
self.mox.StubOutWithMock(self.sa, 'scan')
self.sa.scan(env).AndReturn((True, ['one', 'two']))
self.mox.ReplayAll()
self.sa.apply(env)
self.assertEqual('YES', env.headers['X-Spam-Status'])
self.assertEqual('one, two', env.headers['X-Spam-Symbols'])
开发者ID:slimta,项目名称:python-slimta,代码行数:9,代码来源:test_slimta_policy_spamassassin.py
示例15: test_parse_message_object
def test_parse_message_object(self):
data = Message()
data['From'] = '[email protected]'
data['To'] = '[email protected]'
data['To'] = '[email protected]'
data.set_payload('test test\r\n')
env = Envelope()
env.parse(data)
assert_equal('[email protected]', env.headers['from'])
assert_equal(['[email protected]', '[email protected]'], env.headers.get_all('to'))
assert_equal('test test\r\n', env.message)
开发者ID:drewlander,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_envelope.py
示例16: test_parse_message_object
def test_parse_message_object(self):
msg = Message()
msg['From'] = '[email protected]'
msg['To'] = '[email protected]'
msg['To'] = '[email protected]'
msg.set_payload(b'test test\r\n')
env = Envelope()
env.parse_msg(msg)
self.assertEqual('[email protected]', env.headers['from'])
self.assertEqual(['[email protected]', '[email protected]'], env.headers.get_all('to'))
self.assertEqual(b'test test\r\n', env.message)
开发者ID:madhugb,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_envelope.py
示例17: test_encode_7bit
def test_encode_7bit(self):
headers = Message()
headers['From'] = '[email protected]'
headers['To'] = '[email protected]'
body = ''.join([chr(i) for i in range(129, 256)])
env = Envelope(headers=headers, message=body)
header_str = '\r\n'.join(['From: [email protected]',
'To: [email protected]',
'', ''])
with assert_raises(UnicodeDecodeError):
env.encode_7bit()
开发者ID:drewlander,项目名称:python-slimta,代码行数:11,代码来源:test_slimta_envelope.py
示例18: test_send_envelope_conversion_failure
def test_send_envelope_conversion_failure(self):
result = self.mox.CreateMock(AsyncResult)
env = Envelope('[email protected]', ['[email protected]'])
env.parse('From: [email protected]\r\n\r\ntest test \x81\r\n')
self.sock.sendall('EHLO test\r\n')
self.sock.recv(IsA(int)).AndReturn('250-Hello\r\n250 PIPELINING\r\n')
result.set_exception(IsA(PermanentRelayError))
self.mox.ReplayAll()
client = SmtpRelayClient(None, self.queue, socket_creator=self._socket_creator, ehlo_as='test')
client._connect()
client._ehlo()
client._send_envelope(result, env)
开发者ID:pombredanne,项目名称:python-slimta,代码行数:12,代码来源:test_slimta_relay_smtp_client.py
示例19: test_attempt_timeout
def test_attempt_timeout(self):
self.mox.StubOutWithMock(subprocess, 'Popen')
env = Envelope('[email protected]', ['[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
subprocess.Popen(['maildrop', '-f', '[email protected]'],
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE).AndRaise(Timeout)
self.mox.ReplayAll()
m = MaildropRelay()
with self.assertRaises(TransientRelayError):
m.attempt(env, 0)
开发者ID:slimta,项目名称:python-slimta,代码行数:12,代码来源:test_slimta_relay_pipe.py
示例20: test_send_message_data
def test_send_message_data(self):
env = Envelope('[email protected]', ['[email protected]'])
env.parse(b'From: [email protected]\r\n\r\ntest test\r\n')
self.sock.sendall(b'From: [email protected]\r\n\r\ntest test\r\n.\r\n')
self.sock.recv(IsA(int)).AndReturn(b'250 Ok\r\n')
self.sock.sendall(b'From: [email protected]\r\n\r\ntest test\r\n.\r\n')
self.sock.recv(IsA(int)).AndReturn(b'550 Ok\r\n')
self.mox.ReplayAll()
client = SmtpRelayClient('addr', self.queue, socket_creator=self._socket_creator)
client._connect()
client._send_message_data(env)
with self.assertRaises(PermanentRelayError):
client._send_message_data(env)
开发者ID:thestick613,项目名称:python-slimta,代码行数:13,代码来源:test_slimta_relay_smtp_client.py
注:本文中的slimta.envelope.Envelope类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论