Skip to content

Commit 077ab4b

Browse files
committed
Added download_attachment test
1 parent d3cb707 commit 077ab4b

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎tests/test_mail.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,26 @@ def test_get_text(imapclient):
3636
for mid in message_ids:
3737
for content_type, text in imapclient.get_text(mid):
3838
assert content_type.startswith('text')
39+
40+
def test_download_attachments(imapclient):
41+
message_ids = imapclient.search(['SUBJECT', '빅파이'])
42+
43+
download_files = []
44+
45+
for mid in message_ids:
46+
attachment_list = imapclient.download_attachments(mid)
47+
for filepath in attachment_list:
48+
assert os.path.exists(filepath)
49+
download_files.append(filepath)
50+
51+
for mid in message_ids:
52+
userhome = os.path.expanduser('~')
53+
target_dir = os.path.join(userhome, 'Downloads')
54+
attachment_list = imapclient.download_attachments(mid, target_dir=target_dir)
55+
for filepath in attachment_list:
56+
assert os.path.exists(filepath)
57+
download_files.append(filepath)
58+
59+
60+
for filepath in download_files:
61+
os.unlink(filepath)

0 commit comments

Comments
 (0)