예제 #1
0
 def test_create_measurement_fail_assessment_read_only(self):
     """
     Ensure we cannot create a new measurement when the assessment is read only
     """
     assessment = AssessmentFactory(status="DONE")
     rating = RatingFactory()
     url = reverse('measurement-list')
     data = {
         "id": None,
         "assessment": assessment.id,
         "attribute": rating.attribute.id,
         "rating": rating.id,
         "observations": None,
         "action": "456"
     }
     response = self.client.post(url, data, format='json')
     self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
     self.assertEqual(Measurement.objects.count(), 0)
예제 #2
0
 def test_create_measurement_no_action(self):
     """
     Ensure we can create a new measurement object without an action.
     """
     assessment = AssessmentFactory()
     rating = RatingFactory()
     url = reverse('measurement-list')
     data = {
         "id": None,
         "assessment": assessment.id,
         "attribute": rating.attribute.id,
         "rating": rating.id,
         "observations": "123",
         "action": None
     }
     response = self.client.post(url, data, format='json')
     self.assertEqual(response.status_code, status.HTTP_201_CREATED)
     self.assertEqual(Measurement.objects.count(), 1)
예제 #3
0
 def test_create_measurement_no_rating(self):
     """
     Ensure we can't create a new measurement object without a rating.
     """
     assessment = AssessmentFactory()
     target_rating = RatingFactory()
     url = reverse('measurement-list')
     data = {
         "id": None,
         "assessment": assessment.id,
         "attribute": target_rating.attribute.id,
         "rating": None,
         "target_rating": target_rating.id,
         "observations": "123",
         "action": "456"
     }
     response = self.client.post(url, data, format='json')
     self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
     self.assertEqual(Measurement.objects.count(), 0)