Exemple #1
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'])
    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)