Exemplo n.º 1
0
    def test_create_nodule(self):
        nodule = NoduleFactory()

        # check the centroid location
        self.assertIsInstance(nodule.centroid.x, int)
        self.assertIsInstance(nodule.centroid.y, int)
        self.assertIsInstance(nodule.centroid.z, int)
Exemplo n.º 2
0
    def test_update_nodule_lung_orientation(self):
        nodule = NoduleFactory()
        url = reverse('nodule-update', kwargs={'nodule_id': nodule.id})

        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.NONE.value)

        self.client.post(url, json.dumps({'lung_orientation': 'LEFT'}), 'application/json')
        nodule.refresh_from_db()
        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.LEFT.value)

        self.client.post(url, json.dumps({'lung_orientation': 'RIGHT'}), 'application/json')
        nodule.refresh_from_db()
        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.RIGHT.value)

        self.client.post(url, json.dumps({'lung_orientation': 'NONE'}), 'application/json')
        nodule.refresh_from_db()
        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.NONE.value)
Exemplo n.º 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 a nodule and figure out what we expect to see in the list
        case = CaseFactory()
        nodules = NoduleFactory.create_batch(size=3, case=case)
        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)
Exemplo n.º 4
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()
        nodules = NoduleFactory.create_batch(size=3, case=case)
        request = self.factory.get(url)
        serialized = [NoduleSerializer(n, context={'request': request}) 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)
Exemplo n.º 5
0
    def test_update_nodule_lung_orientation(self):
        nodule = NoduleFactory()
        url = reverse('nodule-detail', kwargs={'pk': nodule.pk})

        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.NONE.value)

        resp = self.client.patch(url, {'lung_orientation': enums.LungOrientation.LEFT.value})
        self.assertEqual(resp.status_code, status.HTTP_200_OK)
        nodule.refresh_from_db()
        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.LEFT.value)

        resp = self.client.patch(url, {'lung_orientation': enums.LungOrientation.RIGHT.value})
        self.assertEqual(resp.status_code, status.HTTP_200_OK)
        nodule.refresh_from_db()
        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.RIGHT.value)

        resp = self.client.patch(url, {'lung_orientation': enums.LungOrientation.NONE.value})
        self.assertEqual(resp.status_code, status.HTTP_200_OK)
        nodule.refresh_from_db()
        self.assertEquals(nodule.lung_orientation, enums.LungOrientation.NONE.value)