Esempio n. 1
0
 def tearDown(self):
     record = Collector.get(self.uuid)
     record.delete()
     if self._testMethodName.startswith('test_post_data'):
         record1 = Collector.get(self.uuid1)
         record1.delete()
Esempio n. 2
0
 def test_invalid_serializer_without_pk(self):
     """test case to test valid function with invalid serializer without pk
     """
     record = Collector.get(self.uuid)
     serializer = CollectorSerializer(record)
     self.assertEqual(serializer.valid(None), False)
Esempio n. 3
0
 def test_update_no_record(self):
     """Test case to update a Collector with None record."""
     serializer = CollectorSerializer(data=None)
     collector = Collector()
     with self.assertRaises(TypeError):
         serializer.update(collector, None)
 def test_get_all_no_record(self):
     """Test case to fetch all Collector with no records present."""
     with self.assertRaises(ResourceNotFound):
         Collector.get_all()
 def test_delete_no_record(self):
     """Test case to delete an invalid Collector record."""
     with self.assertRaises(ResourceNotFound):
         Collector().delete()
 def test_valid_serializer(self):
     """test case to test serializer_valid with valid record"""
     serializer = CollectorSerializer(data=self.data3)
     return_value = Collector.serializer_valid(serializer,
                                               self.uuid)
     self.assertEqual(return_value, True)
 def test_get_no_record(self):
     """Test case to fetch a Collector with invalid record"""
     with self.assertRaises(ResourceNotFound):
         Collector.get(None)
 def test_invalid_serializer_create(self):
     """test case to test serializer_create with invalid record"""
     with self.assertRaises(TypeError):
         Collector.serializer_create(None)
 def test_save_None_record(self):
     """Test case to save None record."""
     with self.assertRaises(TypeError):
         Collector().save()
 def test_valid_get_all_record(self):
     """test case to test get_all with valid record"""
     record = Collector.get_all()
     serializer = CollectorSerializer(record)
     self.listdata.append(self.data)
     self.assertEqual(self.listdata, serializer.data)
 def test_valid_serializer_create(self):
     """test case to test serializer_create with valid record"""
     record = Collector.serializer_create(self.data1)
     serializer = CollectorSerializer(record)
     self.assertEqual(self.data1, serializer.data)
 def test_invalid_get_record(self):
     """test case to test get for invalid id"""
     with self.assertRaises(ResourceNotFound):
         Collector.get(generate_uuid())
 def test_valid_get_record(self):
     """test case to test with valid record"""
     record = Collector.get(self.uuid)
     serializer = CollectorSerializer(record)
     self.assertEqual(self.data, serializer.data)
 def test_delete_invalid_record(self):
     """test case to test delete with invalid record"""
     collector = Collector(**self.data2)
     with self.assertRaises(ResourceNotFound):
         collector.delete()
 def test_delete_valid_record(self):
     """test case to test delete with valid record"""
     record2 = Collector.get(self.uuid)
     record2.delete()
     with self.assertRaises(ResourceNotFound):
         Collector.get(self.uuid)
 def test_save_invalid_record(self):
     """test case to test save with invalid record"""
     with self.assertRaises(TypeError):
         collector = Collector(**self.data2)
         collector.save()