def setUp(self): self.api = API(mode='test', auto_login=False) responses.add( responses.POST, self.get_api_url('API/fundingList/'), body=self.load_xml_response('200_funding_list_page_0.xml'), status=200, content_type='application/xml') self.funding_list = FundingList(api=self.api)
class FundingListTest(TestCase): @responses.activate def setUp(self): self.api = API(mode='test', auto_login=False) responses.add( responses.POST, self.get_api_url('API/fundingList/'), body=self.load_xml_response('200_funding_list_page_0.xml'), status=200, content_type='application/xml') self.funding_list = FundingList(api=self.api) def test_fundings(self): self.assertEqual(len(self.funding_list.fundings), 2) for funding in self.funding_list.fundings: self.assertIsInstance(funding, Funding) def test_number_of_pages(self): self.assertEqual(self.funding_list.number_of_pages, 2) @responses.activate def test_next_page(self): responses.add( responses.POST, self.get_api_url('API/fundingList/'), body=self.load_xml_response('200_funding_list_page_0.xml'), status=200, content_type='application/xml') self.assertEqual(self.funding_list._current_page, 0) self.funding_list.next_page() self.assertEqual(self.funding_list._current_page, 1) self.assertEqual(len(self.funding_list.fundings), 2) # Test it's not possible to scroll past the end of the funding list with self.assertRaises(exceptions.ResourceNotFoundError): self.funding_list.next_page()