POST requests to ListCreateAPIView should create a new object.
(self)
| 111 | assert response.status_code == status.HTTP_200_OK |
| 112 | |
| 113 | def test_post_root_view(self): |
| 114 | """ |
| 115 | POST requests to ListCreateAPIView should create a new object. |
| 116 | """ |
| 117 | data = {'text': 'foobar'} |
| 118 | request = factory.post('/', data, format='json') |
| 119 | with self.assertNumQueries(1): |
| 120 | response = self.view(request).render() |
| 121 | assert response.status_code == status.HTTP_201_CREATED |
| 122 | assert response.data == {'id': 4, 'text': 'foobar'} |
| 123 | created = self.objects.get(id=4) |
| 124 | assert created.text == 'foobar' |
| 125 | |
| 126 | def test_put_root_view(self): |
| 127 | """ |