33import aiohttp
44import asynctest
55from aioresponses import aioresponses
6- from tests .tests_world import FILE_WORLD_FULL , FILE_WORLD_LIST
76
87from tests .tests_character import FILE_CHARACTER_RESOURCE , FILE_CHARACTER_NOT_FOUND
98from tests .tests_guild import FILE_GUILD_FULL , FILE_GUILD_LIST
1211from tests .tests_kill_statistics import FILE_KILL_STATISTICS_FULL
1312from tests .tests_news import FILE_NEWS_LIST , FILE_NEWS_ARTICLE
1413from tests .tests_tibiapy import TestCommons
14+ from tests .tests_world import FILE_WORLD_FULL , FILE_WORLD_LIST
1515from tibiapy import Client , Character , Guild , Highscores , VocationFilter , Category , House , ListedHouse , ListedGuild , \
1616 KillStatistics , ListedNews , News , World , WorldOverview , Forbidden , NetworkError , BoostedCreature
1717
@@ -23,7 +23,8 @@ def setUp(self):
2323 async def tearDown (self ):
2424 await self .client .session .close ()
2525
26- async def testPassSession (self ):
26+ async def test_constructor_pass_session (self ):
27+ """Testing creating an instance passing a session"""
2728 headers = {"User-Agent" : "Python Unit Test" }
2829 session = aiohttp .ClientSession (headers = headers )
2930 client = Client (session = session )
@@ -33,7 +34,8 @@ async def testPassSession(self):
3334 await client .session .close ()
3435
3536 @aioresponses ()
36- async def testRequestErrors (self , mock ):
37+ async def test_handle_errors (self , mock ):
38+ """Testing error handling"""
3739 mock .get (WorldOverview .get_url (), status = 403 )
3840 with self .assertRaises (Forbidden ):
3941 await self .client .fetch_world_list ()
@@ -51,7 +53,8 @@ async def testRequestErrors(self, mock):
5153 await self .client .fetch_recent_news (30 )
5254
5355 @aioresponses ()
54- async def testFetchCharacter (self , mock ):
56+ async def test_fetch_character (self , mock ):
57+ """Testing fetching a character"""
5558 name = "Tschas"
5659 content = self ._load_resource (FILE_CHARACTER_RESOURCE )
5760 mock .get (Character .get_url (name ), status = 200 , body = content )
@@ -60,7 +63,8 @@ async def testFetchCharacter(self, mock):
6063 self .assertIsInstance (character , Character )
6164
6265 @aioresponses ()
63- async def testFetchCharacterNotFound (self , mock ):
66+ async def test_fetch_character_not_found (self , mock ):
67+ """Testing fetching a non existent character"""
6468 name = "Nezune"
6569 content = self ._load_resource (FILE_CHARACTER_NOT_FOUND )
6670 mock .get (Character .get_url (name ), status = 200 , body = content )
@@ -69,7 +73,8 @@ async def testFetchCharacterNotFound(self, mock):
6973 self .assertIsNone (character )
7074
7175 @aioresponses ()
72- async def testFetchGuild (self , mock ):
76+ async def test_fetch_guild (self , mock ):
77+ """Testing fetching a guild"""
7378 name = "Vitam et Mortem"
7479 content = self ._load_resource (FILE_GUILD_FULL )
7580 mock .get (Guild .get_url (name ), status = 200 , body = content )
@@ -78,7 +83,8 @@ async def testFetchGuild(self, mock):
7883 self .assertIsInstance (guild , Guild )
7984
8085 @aioresponses ()
81- async def testFetchGuildList (self , mock ):
86+ async def test_fetch_world_guilds (self , mock ):
87+ """Testing fetching a world's guild list"""
8288 world = "Zuna"
8389 content = self ._load_resource (FILE_GUILD_LIST )
8490 mock .get (ListedGuild .get_world_list_url (world ), status = 200 , body = content )
@@ -87,7 +93,8 @@ async def testFetchGuildList(self, mock):
8793 self .assertIsInstance (guilds [0 ], ListedGuild )
8894
8995 @aioresponses ()
90- async def testFetchHighscores (self , mock ):
96+ async def test_fetch_highscores_page (self , mock ):
97+ """Testing fetching a highscores page"""
9198 world = "Estela"
9299 category = Category .MAGIC_LEVEL
93100 vocations = VocationFilter .KNIGHTS
@@ -98,7 +105,8 @@ async def testFetchHighscores(self, mock):
98105 self .assertIsInstance (highscores , Highscores )
99106
100107 @aioresponses ()
101- async def testFetchHouse (self , mock ):
108+ async def test_fetch_house (self , mock ):
109+ """Testing fetching a house"""
102110 world = "Antica"
103111 house_id = 5236
104112 content = self ._load_resource (FILE_HOUSE_FULL )
@@ -108,7 +116,8 @@ async def testFetchHouse(self, mock):
108116 self .assertIsInstance (house , House )
109117
110118 @aioresponses ()
111- async def testFetchHouseList (self , mock ):
119+ async def test_fetch_world_houses (self , mock ):
120+ """Testing fetching a world's houses"""
112121 world = "Antica"
113122 city = "Edron"
114123 content = self ._load_resource (FILE_HOUSE_LIST )
@@ -119,7 +128,8 @@ async def testFetchHouseList(self, mock):
119128 self .assertIsInstance (houses [0 ], ListedHouse )
120129
121130 @aioresponses ()
122- async def testFetchKillStatistics (self , mock ):
131+ async def test_fetch_kill_statistics (self , mock ):
132+ """Testing fetching kill statistics"""
123133 world = "Antica"
124134 content = self ._load_resource (FILE_KILL_STATISTICS_FULL )
125135 mock .get (KillStatistics .get_url (world ), status = 200 , body = content )
@@ -128,22 +138,25 @@ async def testFetchKillStatistics(self, mock):
128138 self .assertIsInstance (kill_statistics , KillStatistics )
129139
130140 @aioresponses ()
131- async def testFetchRecentNews (self , mock ):
141+ async def test_fetch_recent_news (self , mock ):
142+ """Testing fetching recent nows"""
132143 content = self ._load_resource (FILE_NEWS_LIST )
133144 mock .post (ListedNews .get_list_url (), status = 200 , body = content )
134145 recent_news = await self .client .fetch_recent_news (30 )
135146
136147 self .assertIsInstance (recent_news , list )
137148 self .assertIsInstance (recent_news [0 ], ListedNews )
138149
139- async def testFetchNewsInvalidDates (self ):
150+ async def test_fetch_news_archive_invalid_dates (self ):
151+ """Testing fetching news archive with invalid dates"""
140152 today = datetime .date .today ()
141153 yesterday = today - datetime .timedelta (days = 1 )
142154 with self .assertRaises (ValueError ):
143155 await self .client .fetch_news_archive (today , yesterday )
144156
145157 @aioresponses ()
146- async def testFetchNews (self , mock ):
158+ async def test_fetch_news (self , mock ):
159+ """Testing fetch news"""
147160 news_id = 6000
148161 content = self ._load_resource (FILE_NEWS_ARTICLE )
149162 mock .get (News .get_url (news_id ), status = 200 , body = content )
@@ -152,7 +165,8 @@ async def testFetchNews(self, mock):
152165 self .assertIsInstance (news , News )
153166
154167 @aioresponses ()
155- async def testFetchWorld (self , mock ):
168+ async def test_fetch_world (self , mock ):
169+ """Testing fetching a world"""
156170 name = "Antica"
157171 content = self ._load_resource (FILE_WORLD_FULL )
158172 mock .get (World .get_url (name ), status = 200 , body = content )
@@ -161,15 +175,17 @@ async def testFetchWorld(self, mock):
161175 self .assertIsInstance (world , World )
162176
163177 @aioresponses ()
164- async def testFetchWorldList (self , mock ):
178+ async def test_fetch_world_list (self , mock ):
179+ """Testing fetching the world list"""
165180 content = self ._load_resource (FILE_WORLD_LIST )
166181 mock .get (WorldOverview .get_url (), status = 200 , body = content )
167182 worlds = await self .client .fetch_world_list ()
168183
169184 self .assertIsInstance (worlds , WorldOverview )
170185
171186 @aioresponses ()
172- async def testFetchBoostedCreature (self , mock ):
187+ async def test_fetch_boosted_creature (self , mock ):
188+ """Testing fetching the boosted creature"""
173189 content = self ._load_resource (self .FILE_UNRELATED_SECTION )
174190 mock .get (News .get_list_url (), status = 200 , body = content )
175191 creature = await self .client .fetch_boosted_creature ()
0 commit comments