def test_create_failure(self):
"""Integration that asserts error handling of a message to the create channel."""
json_content = self._send_and_consume('websocket.receive', self._build_message("testmodel", {
'action': 'create',
'pk': None,
'request_id': 'client-request-id',
'data': {},
}))
# it should not create an object
self.assertEqual(TestModel.objects.count(), 0)
expected = {
'action': 'create',
'data': None,
'request_id': 'client-request-id',
'errors': [{'name': ['This field is required.']}],
'response_status': 400
}
# it should respond with an error
self.assertEqual(json_content['payload'], expected)
评论列表
文章目录