def test_list_contactmomenten(self): list_url = reverse(ContactMoment) ContactMomentFactory.create_batch(2) response = self.client.get(list_url) self.assertEqual(response.status_code, status.HTTP_200_OK) data = response.json() self.assertEqual(len(data["results"]), 2)
def test_pagination_page_param(self): ContactMomentFactory.create_batch(2) url = reverse(ContactMoment) response = self.client.get(url, {"page": 1}) self.assertEqual(response.status_code, status.HTTP_200_OK) response_data = response.json() self.assertEqual(response_data["count"], 2) self.assertIsNone(response_data["previous"]) self.assertIsNone(response_data["next"])
def test_list_contactmomenten_filter_volgend_contactmoment(self): list_url = reverse(ContactMoment) cmc1, cmc2, cmc3 = ContactMomentFactory.create_batch(3) cmc3.vorig_contactmoment = cmc2 cmc3.save() response = self.client.get( list_url, {"volgendContactmoment": f"http://testserver.com{reverse(cmc3)}"}, HTTP_HOST="testserver.com", ) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.data["results"]), 1) self.assertEqual( response.data["results"][0]["volgend_contactmoment"], f"http://testserver.com{reverse(cmc3)}", )