1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

[#96] Fixing handling for unicode filename retrieval on python 2.

This commit is contained in:
Adam Coddington 2016-05-14 23:31:55 -07:00
parent a9b7f2d171
commit 1c29cefa08
2 changed files with 7 additions and 7 deletions

View file

@ -723,7 +723,7 @@ class MessageAttachment(models.Model):
def get_filename(self):
"""Returns the original filename of this attachment."""
file_name = self._get_rehydrated_headers().get_filename()
if isinstance(file_name, six.text_type):
if isinstance(file_name, six.string_types):
result = utils.convert_header_to_unicode(file_name)
if result is None:
return file_name

View file

@ -50,18 +50,18 @@ class TestProcessEmail(EmailMessageTestCase):
attachments = msg.attachments.order_by('pk').all()
self.assertEqual(
'\u041f\u0430\u043a\u0435\u0442 \u043f\u0440\u0435\u0434\u043b'
'\u043e\u0436\u0435\u043d\u0438\u0439 HSE Career Fair 8 \u0430'
'\u043f\u0440\u0435\u043b\u044f 2016.pdf',
u'\u041f\u0430\u043a\u0435\u0442 \u043f\u0440\u0435\u0434\u043b'
u'\u043e\u0436\u0435\u043d\u0438\u0439 HSE Career Fair 8 \u0430'
u'\u043f\u0440\u0435\u043b\u044f 2016.pdf',
attachments[0].get_filename()
)
self.assertEqual(
'\u0412\u0435\u0434\u043e\u043c\u043e\u0441\u0442\u0438.pdf',
u'\u0412\u0435\u0434\u043e\u043c\u043e\u0441\u0442\u0438.pdf',
attachments[1].get_filename()
)
self.assertEqual(
'\u041f\u0430\u043a\u0435\u0442 \u043f\u0440\u0435\u0434\u043b'
'\u043e\u0436\u0435\u043d\u0438\u0439 2016.pptx',
u'\u041f\u0430\u043a\u0435\u0442 \u043f\u0440\u0435\u0434\u043b'
u'\u043e\u0436\u0435\u043d\u0438\u0439 2016.pptx',
attachments[2].get_filename()
)