Skip to content

Commit 2bd536c

Browse files
committed
Added test cases for auxiliary auction methods
1 parent 5fff757 commit 2bd536c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/tests_client.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import datetime
2+
import unittest.mock
23

34
import aiohttp
45
import asynctest
56
from aioresponses import aioresponses
67

8+
import tibiapy
79
from tests.tests_bazaar import FILE_BAZAAR_CURRENT, FILE_BAZAAR_HISTORY, FILE_AUCTION_FINISHED
810
from tests.tests_character import FILE_CHARACTER_RESOURCE, FILE_CHARACTER_NOT_FOUND
911
from 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

Comments
 (0)