diff --git a/rest_framework/tests/generics.py b/rest_framework/tests/generics.py index 4799a04b5..ebe415765 100644 --- a/rest_framework/tests/generics.py +++ b/rest_framework/tests/generics.py @@ -42,15 +42,15 @@ class SlugBasedInstanceView(InstanceView): class TestRootView(TestCase): def setUp(self): """ - Create 3 BasicModel intances. + Create 3 BasicModel instances. """ items = ['foo', 'bar', 'baz'] for item in items: BasicModel(text=item).save() self.objects = BasicModel.objects self.data = [ - {'id': obj.id, 'text': obj.text} - for obj in self.objects.all() + {'id': obj.id, 'text': obj.text} + for obj in self.objects.all() ] self.view = RootView.as_view() @@ -69,7 +69,7 @@ class TestRootView(TestCase): """ content = {'text': 'foobar'} request = factory.post('/', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request).render() self.assertEquals(response.status_code, status.HTTP_201_CREATED) self.assertEquals(response.data, {'id': 4, 'text': u'foobar'}) @@ -82,7 +82,7 @@ class TestRootView(TestCase): """ content = {'text': 'foobar'} request = factory.put('/', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request).render() self.assertEquals(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) self.assertEquals(response.data, {"detail": "Method 'PUT' not allowed."}) @@ -124,7 +124,7 @@ class TestRootView(TestCase): """ content = {'id': 999, 'text': 'foobar'} request = factory.post('/', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request).render() self.assertEquals(response.status_code, status.HTTP_201_CREATED) self.assertEquals(response.data, {'id': 4, 'text': u'foobar'}) @@ -142,8 +142,8 @@ class TestInstanceView(TestCase): BasicModel(text=item).save() self.objects = BasicModel.objects self.data = [ - {'id': obj.id, 'text': obj.text} - for obj in self.objects.all() + {'id': obj.id, 'text': obj.text} + for obj in self.objects.all() ] self.view = InstanceView.as_view() self.slug_based_view = SlugBasedInstanceView.as_view() @@ -163,7 +163,7 @@ class TestInstanceView(TestCase): """ content = {'text': 'foobar'} request = factory.post('/', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request).render() self.assertEquals(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) self.assertEquals(response.data, {"detail": "Method 'POST' not allowed."}) @@ -174,7 +174,7 @@ class TestInstanceView(TestCase): """ content = {'text': 'foobar'} request = factory.put('/1', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request, pk='1').render() self.assertEquals(response.status_code, status.HTTP_200_OK) self.assertEquals(response.data, {'id': 1, 'text': 'foobar'}) @@ -187,7 +187,7 @@ class TestInstanceView(TestCase): """ content = {'text': 'foobar'} request = factory.patch('/1', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request, pk=1).render() self.assertEquals(response.status_code, status.HTTP_200_OK) @@ -234,7 +234,7 @@ class TestInstanceView(TestCase): """ content = {'id': 999, 'text': 'foobar'} request = factory.put('/1', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request, pk=1).render() self.assertEquals(response.status_code, status.HTTP_200_OK) self.assertEquals(response.data, {'id': 1, 'text': 'foobar'}) @@ -249,7 +249,7 @@ class TestInstanceView(TestCase): self.objects.get(id=1).delete() content = {'text': 'foobar'} request = factory.put('/1', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request, pk=1).render() self.assertEquals(response.status_code, status.HTTP_201_CREATED) self.assertEquals(response.data, {'id': 1, 'text': 'foobar'}) @@ -264,7 +264,7 @@ class TestInstanceView(TestCase): content = {'text': 'foobar'} # pk fields can not be created on demand, only the database can set th pk for a new object request = factory.put('/5', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request, pk=5).render() self.assertEquals(response.status_code, status.HTTP_201_CREATED) new_obj = self.objects.get(pk=5) @@ -277,7 +277,7 @@ class TestInstanceView(TestCase): """ content = {'text': 'foobar'} request = factory.put('/test_slug', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.slug_based_view(request, slug='test_slug').render() self.assertEquals(response.status_code, status.HTTP_201_CREATED) self.assertEquals(response.data, {'slug': 'test_slug', 'text': 'foobar'}) @@ -311,7 +311,7 @@ class TestCreateModelWithAutoNowAddField(TestCase): """ content = {'email': 'foobar@example.com', 'content': 'foobar'} request = factory.post('/', json.dumps(content), - content_type='application/json') + content_type='application/json') response = self.view(request).render() self.assertEquals(response.status_code, status.HTTP_201_CREATED) created = self.objects.get(id=1)