|
4 | 4 | import asynctest
|
5 | 5 | from aioresponses import aioresponses
|
6 | 6 |
|
7 |
| -from tests.tests_bazaar import FILE_BAZAAR_CURRENT |
| 7 | +from tests.tests_bazaar import FILE_BAZAAR_CURRENT, FILE_BAZAAR_HISTORY, FILE_AUCTION_FINISHED |
8 | 8 | from tests.tests_character import FILE_CHARACTER_RESOURCE, FILE_CHARACTER_NOT_FOUND
|
| 9 | +from tests.tests_events import FILE_EVENT_CALENDAR |
9 | 10 | from tests.tests_forums import FILE_CM_POST_ARCHIVE_PAGES
|
10 | 11 | from tests.tests_guild import FILE_GUILD_FULL, FILE_GUILD_LIST
|
11 | 12 | from tests.tests_highscores import FILE_HIGHSCORES_FULL
|
|
17 | 18 | from tibiapy import CharacterBazaar, Client, Character, CMPostArchive, Guild, Highscores, VocationFilter, Category, \
|
18 | 19 | House, ListedHouse, \
|
19 | 20 | ListedGuild, \
|
20 |
| - KillStatistics, ListedNews, News, World, WorldOverview, Forbidden, NetworkError, Creature |
| 21 | + KillStatistics, ListedNews, News, World, WorldOverview, Forbidden, NetworkError, Creature, AuctionDetails, \ |
| 22 | + EventSchedule |
21 | 23 |
|
22 | 24 |
|
23 | 25 | class TestClient(asynctest.TestCase, TestCommons):
|
@@ -229,4 +231,46 @@ async def test_client_fetch_current_auctions(self, mock):
|
229 | 231 | response = await self.client.fetch_current_auctions()
|
230 | 232 | self.assertIsInstance(response.data, CharacterBazaar)
|
231 | 233 |
|
| 234 | + async def test_client_fetch_current_auctions_invalid_page(self): |
| 235 | + """Testing fetching the current auctions with an invalid page""" |
| 236 | + with self.assertRaises(ValueError): |
| 237 | + await self.client.fetch_current_auctions(-1) |
| 238 | + |
| 239 | + @aioresponses() |
| 240 | + async def test_client_fetch_auction_history(self, mock): |
| 241 | + """Testing fetching the auction history""" |
| 242 | + content = self.load_resource(FILE_BAZAAR_HISTORY) |
| 243 | + mock.get(CharacterBazaar.get_auctions_history_url(), status=200, body=content) |
| 244 | + response = await self.client.fetch_auction_history() |
| 245 | + self.assertIsInstance(response.data, CharacterBazaar) |
| 246 | + |
| 247 | + async def test_client_fetch_auction_history_invalid_page(self): |
| 248 | + """Testing fetching the auction history with an incorrect page""" |
| 249 | + with self.assertRaises(ValueError): |
| 250 | + await self.client.fetch_auction_history(-1) |
232 | 251 |
|
| 252 | + @aioresponses() |
| 253 | + async def test_client_fetch_auction(self, mock): |
| 254 | + """Testing fetching an auction""" |
| 255 | + content = self.load_resource(FILE_AUCTION_FINISHED) |
| 256 | + mock.get(AuctionDetails.get_url(134), status=200, body=content) |
| 257 | + response = await self.client.fetch_auction(134) |
| 258 | + self.assertIsInstance(response.data, AuctionDetails) |
| 259 | + |
| 260 | + async def test_client_fetch_auction_invalid_id(self): |
| 261 | + """Testing fetching an auction with an invalid id""" |
| 262 | + with self.assertRaises(ValueError): |
| 263 | + await self.client.fetch_auction(-1) |
| 264 | + |
| 265 | + @aioresponses() |
| 266 | + async def test_client_fetch_event_calendar(self, mock): |
| 267 | + """Testing fetching the auction history""" |
| 268 | + content = self.load_resource(FILE_EVENT_CALENDAR) |
| 269 | + mock.get(EventSchedule.get_url(), status=200, body=content) |
| 270 | + response = await self.client.fetch_event_schedule() |
| 271 | + self.assertIsInstance(response.data, EventSchedule) |
| 272 | + |
| 273 | + async def test_client_fetch_event_calendar_invalid_params(self): |
| 274 | + """Testing fetching the auction history""" |
| 275 | + with self.assertRaises(ValueError): |
| 276 | + await self.client.fetch_event_schedule(3) |
0 commit comments