Example #1
0
    def test_update_id(self):
        """test case to test update function with id update"""
        obj = NetFlowMonitor.get(self.uuid)
        serializer_data1 = json.loads(json.dumps(self.data1))
#        for serializerdata1 in serializer_data1:
        with self.assertRaises(IDUpdateNotPermitted):
            serializer = NetFlowMonitorSerializer(obj,
                                                  data=serializer_data1[0],
                                                  partial=True,
                                                  context={'pk': self.uuid1})
            serializer.update(obj, serializer_data1[0])
Example #2
0
    def test_put_Data(self):
        """test case to test update function with valid data"""
        obj = NetFlowMonitor.get(self.uuid)
        serializer_data2 = json.loads(json.dumps(self.data2))
#        for serializerdata2 in serializer_data2:
        serializer = NetFlowMonitorSerializer(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)
Example #3
0
 def tearDown(self):
     record = NetFlowMonitor.get(self.uuid)
     record.delete()
     if self._testMethodName.startswith('test_post_data'):
         record1 = NetFlowMonitor.get(self.uuid1)
         record1.delete()
Example #4
0
 def test_delete_no_record(self):
     """Test case to delete an invalid NetFlowMonitor record."""
     with self.assertRaises(ResourceNotFound):
         NetFlowMonitor().delete()
Example #5
0
 def test_get_all_no_record(self):
     """Test case to fetch all NetFlowMonitor with no records present."""
     with self.assertRaises(ResourceNotFound):
         NetFlowMonitor.get_all()
Example #6
0
 def test_get_no_record(self):
     """Test case to fetch a NetFlowMonitor with invalid id."""
     with self.assertRaises(ResourceNotFound):
         NetFlowMonitor.get(generate_uuid())
Example #7
0
 def test_save_None_record(self):
     """Test case to save None record."""
     with self.assertRaises(TypeError):
         NetFlowMonitor().save()
Example #8
0
 def test_invalid_serializer_without_pk(self):
     """test case to test valid function with invalid serializer without pk
     """
     record = NetFlowMonitor.get(self.uuid)
     serializer = NetFlowMonitorSerializer(record)
     self.assertEqual(serializer.valid(None), False)