def test_unallowed_file(self):
"""
Tests the get_file_path function for an unallowed file type.
"""
self.mock_mailsifter_settings['ALLOWED_EMAIL_ATTACHMENTS'] = ('application/java',)
with patch.dict('sifter.mailsifter.accessors.settings.MAILSIFTER',
self.mock_mailsifter_settings):
self.msg.attach(self.java)
attachment = get_first_attachment(self.msg)
with patch('sifter.mailsifter.attachments.settings',
return_value=self.mock_settings):
with LogCapture() as log_capture:
actual = attachments.get_file_path(attachment)
expected = None
self.assertEqual(actual, expected)
msg = 'The attachment %s is not an allowed file type' \
% self.java_file
log_capture.check(
('sifter.mailsifter.attachments', 'WARNING', msg),
)
评论列表
文章目录