本文整理汇总了Python中pixelated.adapter.mailstore.leap_mailstore.LeapMailStore.get_mail_attachment方法的典型用法代码示例。如果您正苦于以下问题:Python LeapMailStore.get_mail_attachment方法的具体用法?Python LeapMailStore.get_mail_attachment怎么用?Python LeapMailStore.get_mail_attachment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pixelated.adapter.mailstore.leap_mailstore.LeapMailStore
的用法示例。
在下文中一共展示了LeapMailStore.get_mail_attachment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_mail_attachment_throws_exception_if_attachment_does_not_exist
# 需要导入模块: from pixelated.adapter.mailstore.leap_mailstore import LeapMailStore [as 别名]
# 或者: from pixelated.adapter.mailstore.leap_mailstore.LeapMailStore import get_mail_attachment [as 别名]
def test_get_mail_attachment_throws_exception_if_attachment_does_not_exist(self):
attachment_id = '1B0A9AAD9E153D24265395203C53884506ABA276394B9FEC02B214BF9E77E48E'
when(self.soledad).get_from_index('by-type-and-payloadhash', 'cnt', attachment_id).thenReturn(defer.succeed([]))
store = LeapMailStore(self.soledad)
try:
yield store.get_mail_attachment(attachment_id)
self.fail('ValueError exception expected')
except ValueError:
pass
示例2: test_get_mail_attachment
# 需要导入模块: from pixelated.adapter.mailstore.leap_mailstore import LeapMailStore [as 别名]
# 或者: from pixelated.adapter.mailstore.leap_mailstore.LeapMailStore import get_mail_attachment [as 别名]
def test_get_mail_attachment(self):
attachment_id = 'AAAA9AAD9E153D24265395203C53884506ABA276394B9FEC02B214BF9E77E48E'
doc = SoledadDocument(json=json.dumps({'content_type': 'foo/bar', 'raw': 'asdf'}))
when(self.soledad).get_from_index('by-type-and-payloadhash', 'cnt', attachment_id).thenReturn(defer.succeed([doc]))
store = LeapMailStore(self.soledad)
attachment = yield store.get_mail_attachment(attachment_id)
self.assertEqual({'content-type': 'foo/bar', 'content': bytearray('asdf')}, attachment)
示例3: test_get_mail_attachment_different_content_encodings
# 需要导入模块: from pixelated.adapter.mailstore.leap_mailstore import LeapMailStore [as 别名]
# 或者: from pixelated.adapter.mailstore.leap_mailstore.LeapMailStore import get_mail_attachment [as 别名]
def test_get_mail_attachment_different_content_encodings(self):
attachment_id = '1B0A9AAD9E153D24265395203C53884506ABA276394B9FEC02B214BF9E77E48E'
encoding_examples = [('', 'asdf', 'asdf'),
('base64', 'asdf', 'YXNkZg=='),
('quoted-printable', 'äsdf', '=C3=A4sdf')]
for transfer_encoding, data, encoded_data in encoding_examples:
doc = SoledadDocument(json=json.dumps({'content_type': 'foo/bar', 'raw': encoded_data,
'content_transfer_encoding': transfer_encoding}))
when(self.soledad).get_from_index('by-type-and-payloadhash', 'cnt', attachment_id).thenReturn(defer.succeed([doc]))
store = LeapMailStore(self.soledad)
attachment = yield store.get_mail_attachment(attachment_id)
self.assertEqual(bytearray(data), attachment['content'])