def test_integrity_error(self):
"""
Tests the configuration test tool when an IntegrityError is raised.
"""
self.page.config_test_value = json.dumps({'text': 'test'})
with patch('django.forms.ModelForm.save',
side_effect=IntegrityError('foo')):
with LogCapture('cyphon.admin') as log_capture:
actual = self.page.run_test()
expected = "Could not create an object for testing: foo"
self.assertEqual(actual, expected)
msg = 'An error occurred while creating a test instance: ' + \
'<WSGIRequest: POST ' + \
"'/admin/datacondensers/datacondenser/1/change/test/'>"
log_capture.check(
('cyphon.admin', 'ERROR', msg),
)
评论列表
文章目录