def test_update_id(self): """test case to test update function with id update""" obj = RawForwardAssociation.get(self.uuid) serializer_data1 = json.loads(json.dumps(self.data1)) # for serializerdata1 in serializer_data1: with self.assertRaises(IDUpdateNotPermitted): serializer = RawForwardAssociationSerializer( 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 = RawForwardAssociation.get(self.uuid) serializer_data2 = json.loads(json.dumps(self.data2)) # for serializerdata2 in serializer_data2: serializer = RawForwardAssociationSerializer(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 = RawForwardAssociation.get(self.uuid) record.delete() if self._testMethodName.startswith('test_post_data'): record1 = RawForwardAssociation.get(self.uuid1) record1.delete()
def test_delete_no_record(self): """Test case to delete an invalid RawForwardAssociation record.""" with self.assertRaises(ResourceNotFound): RawForwardAssociation().delete()
def test_get_all_no_record(self): """Test case to fetch all RawForwardAssociation with no records present """ with self.assertRaises(ResourceNotFound): RawForwardAssociation.get_all()
def test_get_no_record(self): """Test case to fetch a RawForwardAssociation with invalid id.""" with self.assertRaises(ResourceNotFound): RawForwardAssociation.get(generate_uuid())
def test_save_None_record(self): """Test case to save None record.""" with self.assertRaises(TypeError): RawForwardAssociation().save()
def test_invalid_serializer_without_pk(self): """test case to test valid function with invalid serializer without pk """ record = RawForwardAssociation.get(self.uuid) serializer = RawForwardAssociationSerializer(record) self.assertEqual(serializer.valid(None), False)