test_models.py 文件源码

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

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
def test_natural_key_exception():
        """
        Tests the get_by_natural_key method for a ContextFilter that
        doesn't exist.
        """
        with LogCapture() as log_capture:
            key = ['dummy_context', 'mongodb', 'test_database', 'test_posts',
                   'host', 'from']
            ContextFilter.objects.get_by_natural_key(*key)
            expected_1 = ('Context dummy_context:mongodb.test_database.'
                          'test_posts does not exist')
            expected_2 = ('ContextFilter dummy_context:mongodb.test_database.'
                          'test_posts (host -> from) does not exist')
            log_capture.check(
                ('contexts.models', 'ERROR', expected_1),
                ('contexts.models', 'ERROR', expected_2)
            )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号