test_attachments.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
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),
                    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号