Beispiel #1
0
    def test_candidates_dismiss(self):
        candidate = CandidateFactory()
        url = reverse('review-candidate', kwargs={'candidate_id': candidate.id})
        self.client.post(url, json.dumps({'review_result': enums.CandidateReviewResult.DISMISSED}), 'application/json')

        candidate.refresh_from_db()

        self.assertEquals(candidate.review_result, enums.CandidateReviewResult.DISMISSED)
Beispiel #2
0
 def test_candidates_dismiss(self):
     candidate = CandidateFactory()
     url = reverse('candidate-dismiss', kwargs={'candidate_id': candidate.id})
     response = self.client.get(url)
     response_dict = response.json()
     self.assertEqual(response_dict["response"], "Candidate {} was dismissed".format(candidate.id))
     self.assertEqual(response.status_code, status.HTTP_200_OK)
Beispiel #3
0
    def test_nodule_list_viewset(self):
        # first try an endpoint without a nodule
        url = reverse('nodule-list')
        response = self.client.get(url)
        payload = response.json()
        self.assertListEqual(payload, [])

        # now create nodules and figure out what we expect to see in the list
        case = CaseFactory()
        candidates = CandidateFactory.create_batch(size=3, case=case)
        nodules = []
        for candidate in candidates:
            nodule, _ = candidate.get_or_create_nodule()
            nodules.append(nodule)
        serialized = [
            NoduleSerializer(n, context={'request': None}) for n in nodules
        ]
        expecteds = [json.loads(json.dumps(s.data)) for s in serialized]

        # check the actual response
        response = self.client.get(url)
        payload = response.json()
        self.maxDiff = 2000
        for actual, expected in zip(payload, expecteds):
            self.assertDictEqual(actual['candidate']['centroid'],
                                 expected['candidate']['centroid'])
            self.assertEqual(actual['url'], expected['url'])
Beispiel #4
0
    def test_candidates_mark(self):
        candidate = CandidateFactory()

        url = reverse('candidate-detail', kwargs={'pk': candidate.id})
        response = self.client.patch(url, {'review_result': enums.CandidateReviewResult.MARKED.value})

        self.assertEqual(response.status_code, status.HTTP_200_OK)
Beispiel #5
0
    def test_create_candidate(self):
        candidate = CandidateFactory()

        # check p(concerning)
        self.assertGreater(candidate.probability_concerning, 0.0)
        self.assertLess(candidate.probability_concerning, 1.0)

        # check the centroid location
        self.assertIsInstance(candidate.centroid.x, int)
        self.assertIsInstance(candidate.centroid.y, int)
        self.assertIsInstance(candidate.centroid.z, int)
Beispiel #6
0
    def test_nodule_list_viewset(self):
        # first try an endpoint without a nodule
        url = reverse('nodule-list')
        response = self.client.get(url)
        payload = response.json()
        self.assertListEqual(payload, [])

        # now create a nodule and figure out what we expect to see in the list
        case = CaseFactory()
        candidates = CandidateFactory.create_batch(size=3, case=case)
        nodules = []
        for candidate in candidates:
            nodule, _ = candidate.get_or_create_nodule()
            nodules.append(nodule)
        serialized = [
            NoduleSerializer(n, context={'request': None}) for n in nodules
        ]
        expected = [s.data for s in serialized]

        # check the actual response
        response = self.client.get(url)
        payload = response.json()
        self.assertListEqual(payload, expected)