def test_create(self):
"""Integration that asserts routing a message to the create channel.
Asserts response is correct and an object is created.
"""
json_content = self._send_and_consume("websocket.receive", self._build_message("testmodel", {
'action': 'create',
'pk': None,
'request_id': 'client-request-id',
'data': {'name': 'some-thing'}
}))
# it should create an object
self.assertEqual(TestModel.objects.count(), 1)
expected = {
'action': 'create',
'data': TestModelSerializer(TestModel.objects.first()).data,
'errors': [],
'request_id': 'client-request-id',
'response_status': 201
}
# it should respond with the serializer.data
self.assertEqual(json_content['payload'], expected)
评论列表
文章目录