def test_update_id(self):
     """test case to test update function with id update"""
     obj = Policy.get(self.uuid)
     serializer_data1 = json.loads(json.dumps(self.data1))
     #        for serializerdata1 in serializer_data1:
     with self.assertRaises(IDUpdateNotPermitted):
         serializer = PolicySerializer(obj,
                                       data=serializer_data1[0],
                                       partial=True,
                                       context={'pk': self.uuid1})
         serializer.update(obj, serializer_data1[0])
 def test_put_Data(self):
     """test case to test update function with valid data"""
     obj = Policy.get(self.uuid)
     serializer_data2 = json.loads(json.dumps(self.data2))
     #        for serializerdata2 in serializer_data2:
     serializer = PolicySerializer(obj,
                                   data=serializer_data2[0],
                                   partial=True,
                                   context={'pk': self.uuid})
     serializer.update(obj, serializer_data2[0])
     serializerdata2 = serializer_data2[0]
     serializerdata2['id'] = self.uuid
     self.assertEqual(serializerdata2, serializer.data)
 def tearDown(self):
     record = Policy.get(self.uuid)
     record.delete()
     if self._testMethodName.startswith('test_post_data'):
         record1 = Policy.get(self.uuid1)
         record1.delete()
 def test_get_no_record(self):
     """Test case to fetch a Policy with invalid id."""
     with self.assertRaises(ResourceNotFound):
         Policy.get(generate_uuid())
 def test_invalid_serializer_without_pk(self):
     """test case to test valid function with invalid serializer without pk
     """
     record = Policy.get(self.uuid)
     serializer = PolicySerializer(record)
     self.assertEqual(serializer.valid(None), False)