Esempio n. 1
0
 def test_processlog_view_get_all(self, mock_date):
     mock_date.return_value = self.date
     response = self.client.get('/hierarchy/processlog/')
     expected = ProcessLogSerializer(
         ProcessLog.objects.all().order_by('-id'), many=True).data
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data, expected)
Esempio n. 2
0
 def test_processlog_view_get_filter_name(self, mock_date):
     mock_date.return_value = self.date
     response = self.client.get('/hierarchy/processlog/?description=desc')
     expected = ProcessLogSerializer(ProcessLog.objects.all().filter(
         description__icontains='desc').order_by('-id'),
                                     many=True).data
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data, expected)
Esempio n. 3
0
 def test_processlog_view_get_filter_dates(self):
     response = self.client.get(
         '/hierarchy/processlog/?startdate=082516&enddate=090216')
     expected = ProcessLogSerializer(ProcessLog.objects.all().filter(
         timestamp__range=(dt(2016, 8, 25),
                           dt(2016, 9, 2))).order_by('-id'),
                                     many=True).data
     self.assertEqual(response.status_code, 200)
     self.assertEqual(response.data, expected)
Esempio n. 4
0
 def test_serializer_missing(self):
     serializer = ProcessLogSerializer(data=self.datapoint_missing)
     self.assertFalse(serializer.is_valid())
     self.assertEqual(len(serializer.errors), len(self.missing_checks))
     for field in self.missing_checks:
         self.assertTrue(field in serializer.errors)
Esempio n. 5
0
 def test_serializer_good(self):
     self.assertTrue(ProcessLogSerializer(data=self.datapoint).is_valid())