11import datetime
2+ import unittest .mock
23
34import aiohttp
45import asynctest
56from aioresponses import aioresponses
67
8+ import tibiapy
79from tests .tests_bazaar import FILE_BAZAAR_CURRENT , FILE_BAZAAR_HISTORY , FILE_AUCTION_FINISHED
810from tests .tests_character import FILE_CHARACTER_RESOURCE , FILE_CHARACTER_NOT_FOUND
911from tests .tests_events import FILE_EVENT_CALENDAR
@@ -274,3 +276,18 @@ async def test_client_fetch_event_calendar_invalid_params(self):
274276 """Testing fetching the auction history"""
275277 with self .assertRaises (ValueError ):
276278 await self .client .fetch_event_schedule (3 )
279+
280+ @unittest .mock .patch ("tibiapy.bazaar.AuctionDetails._parse_page_items" )
281+ async def test_client__fetch_all_pages_success (self , parse_page_items ):
282+ """Testing internal method to fetch all pages of an auction item collection."""
283+ paginator = tibiapy .ItemSummary (page = 1 , total_pages = 5 )
284+ self .client ._fetch_ajax_page = unittest .mock .AsyncMock ()
285+
286+ await self .client ._fetch_all_pages (1 , paginator , 1 )
287+
288+ self .assertEqual (4 , self .client ._fetch_ajax_page .await_count )
289+ self .assertEqual (4 , parse_page_items .call_count )
290+
291+ async def test_client__fetch_all_pages_none_input (self ):
292+ """Testing internal method to fetch all pages of an auction item collection."""
293+ self .assertIsNone (await self .client ._fetch_all_pages (1 , None , 1 ))
0 commit comments