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)
)
评论列表
文章目录