def test_put_or_update_non_existing_blog(self): """ Testcase to test PUT / UPDATE a non existing blog """ # input dict to test the POST input_data = BlogSerializer(self.blog).data input_data.update({"title": "changed"}) puturl = '%s%d' % (self.url, 200) response = self.client.put(puturl, data=json.dumps(input_data), content_type='application/json') self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
def test_put_or_update_blog_invalid_input_format(self): """ Testcase to test PUT / UPDATE input is not in proper json format """ # input dict to test the POST input_data = BlogSerializer(self.blog).data input_data.update({'title': 'changed'}) puturl = '%s%d' % (self.url, self.blog.id) response = self.client.put(puturl, data=input_data, content_type='application/json') #data = response.json() self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
def test_put_or_update_existing_blog(self): """ Testcase to test PUT / UPDATE a existing blog """ # input dict to test the POST input_data = BlogSerializer(self.blog).data input_data.update({"title":"changed"}) puturl='%s%d'%(self.url,self.blog.id) response = self.client.put(puturl, data=json.dumps(input_data), content_type='application/json') data = response.json() self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIn('title', response.json()) self.assertEqual(data['title'], input_data['title'])
def test_put_or_update_existing_blog(self): """ Testcase to test PUT / UPDATE a existing blog """ # input dict to test the POST input_data = BlogSerializer(self.blog).data input_data.update({"title": "changed"}) puturl = '%s%d' % (self.url, self.blog.id) response = self.client.put(puturl, data=json.dumps(input_data), content_type='application/json') data = response.json() self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertIn('title', response.json()) self.assertEqual(data['title'], input_data['title'])