Skip to content

Commit 82327bf

Browse files
committed
Renaming test cases
1 parent 841c15c commit 82327bf

File tree

2 files changed

+68
-35
lines changed

2 files changed

+68
-35
lines changed

tests/tests_character.py

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def _compare_character(self, mock_character, character):
3232
self.assertEqual(mock_character.sex, character.sex)
3333

3434
# region Tibia.com Character Tests
35-
def testCharacter(self):
35+
def test_from_content(self):
36+
"""Testing parsing a character's HTML content"""
3637
character = Character.from_content(self._load_resource(FILE_CHARACTER_RESOURCE))
3738
self._compare_character(Character("Tschas", "Gladera", Vocation.DRUID, 260, Sex.FEMALE), character)
3839
self.assertIsNotNone(character.guild_membership)
@@ -53,12 +54,14 @@ def testCharacter(self):
5354
self.assertEqual(5, len(character.other_characters))
5455
self.assertFalse(character.hidden)
5556

56-
def testCharacterNotFound(self):
57+
def test_from_content_not_found(self):
58+
"""Testing parsing a character not found page"""
5759
content = self._load_resource(FILE_CHARACTER_NOT_FOUND)
5860
char = Character.from_content(content)
5961
self.assertIsNone(char)
6062

61-
def testCharacterFormerNames(self):
63+
def test_from_content_with_former_names(self):
64+
"""Testing parsing a character that has former names"""
6265
content = self._load_resource(FILE_CHARACTER_FORMER_NAMES)
6366
char = Character.from_content(content)
6467
self.assertIsInstance(char.former_names, list)
@@ -71,22 +74,25 @@ def testCharacterFormerNames(self):
7174
self.assertEqual(char.house.world, char.world)
7275
self.assertIsInstance(char.house.paid_until_date, datetime.date)
7376

74-
def testCharacterPosition(self):
77+
def test_from_content_with_position(self):
78+
"""Testing parsing a character with a position"""
7579
content = self._load_resource(FILE_CHARACTER_SPECIAL_POSITION)
7680
char = Character.from_content(content)
7781
self.assertEqual(char.name, "Steve")
7882
self.assertEqual(char.position, "CipSoft Member")
7983
self.assertEqual(char.account_information.position, "CipSoft Member")
8084

81-
def testCharacterDeletion(self):
85+
def test_from_content_deleted_character(self):
86+
"""Testing parsing a character scheduled for deletion"""
8287
content = self._load_resource(FILE_CHARACTER_DELETION)
8388
char = Character.from_content(content)
8489
self.assertEqual("Expendable Dummy", char.name)
8590
self.assertIsNotNone(char.deletion_date)
8691
self.assertIsInstance(char.deletion_date, datetime.datetime)
8792
self.assertEqual(parse_tibia_datetime("Oct 08 2018 22:17:00 CEST"), char.deletion_date)
8893

89-
def testCharacterComplexDeaths(self):
94+
def test_from_content_complex_deaths(self):
95+
"""Testing parsing a character with complex deaths (summons, assists, etc)"""
9096
content = self._load_resource(FILE_CHARACTER_DEATHS_COMPLEX)
9197
char = Character.from_content(content)
9298
self.assertTrue(char.deaths)
@@ -95,7 +101,8 @@ def testCharacterComplexDeaths(self):
95101
oldest_death = char.deaths[-1]
96102
self.assertEqual(oldest_death.killer.summon, "a fire elemental")
97103

98-
def testCharacterBadgesTitles(self):
104+
def test_from_content_badges_and_title(self):
105+
"""Testing parsing a character with account badges and a title"""
99106
content = self._load_resource(FILE_CHARACTER_TITLE_BADGES)
100107
char = Character.from_content(content)
101108
self.assertEqual("Lord Feremis", char.name)
@@ -110,14 +117,16 @@ def testCharacterBadgesTitles(self):
110117
self.assertIsInstance(badge.icon_url, str)
111118
self.assertIsInstance(badge.description, str)
112119

113-
def testCharacterUnrelated(self):
120+
def test_from_content_unrelated(self):
121+
"""Testing parsing an unrelated tibia.com section"""
114122
content = self._load_resource(self.FILE_UNRELATED_SECTION)
115123
with self.assertRaises(InvalidContent):
116124
Character.from_content(content)
117125

118126
# endregion
119127

120-
def testDeathTypes(self):
128+
def test_death_types(self):
129+
"""Testing different death types"""
121130
assisted_suicide = Death("Galarzaa", 280, killers=[Killer("Galarzaa", True), Killer("a pixy")],
122131
time=datetime.datetime.now())
123132
self.assertEqual(assisted_suicide.killer, assisted_suicide.killers[0])
@@ -129,8 +138,9 @@ def testDeathTypes(self):
129138
self.assertTrue(spawn_invasion.by_player)
130139

131140
# region TibiaData Character tests
132-
133-
def testCharacterTibiaData(self):
141+
142+
def test_from_tibiadata(self):
143+
"""Testing parsing TibiaData content"""
134144
content = self._load_resource(FILE_CHARACTER_TIBIADATA)
135145
char = Character.from_tibiadata(content)
136146

@@ -147,7 +157,8 @@ def testCharacterTibiaData(self):
147157

148158
self.assertTrue(char.deaths[3].by_player)
149159

150-
def testCharacterTibiaDataUnhidden(self):
160+
def test_from_tibiadata_unhidden(self):
161+
"""Testing parsing an unhidden character"""
151162
content = self._load_resource(FILE_CHARACTER_TIBIADATA_UNHIDDEN)
152163
char = Character.from_tibiadata(content)
153164

@@ -161,7 +172,8 @@ def testCharacterTibiaDataUnhidden(self):
161172
self.assertEqual(char.house.world, char.world)
162173
self.assertIsInstance(char.house.paid_until_date, datetime.date)
163174

164-
def testCharacterTibiaDataDeleted(self):
175+
def test_from_tibiadata_deleted(self):
176+
"""Testing parsing a deleted character"""
165177
content = self._load_resource(FILE_CHARACTER_TIBIADATA_DELETED)
166178
char = Character.from_tibiadata(content)
167179

@@ -172,14 +184,16 @@ def testCharacterTibiaDataDeleted(self):
172184
self.assertIsNone(char.guild_name)
173185
self.assertIsNone(char.last_login)
174186

175-
def testCharacterTibiaDataPosition(self):
187+
def test_from_tibiadata_position(self):
188+
"""Testing parsing a character with position"""
176189
content = self._load_resource(FILE_CHARACTER_TIBIADATA_SPECIAL_POSITION)
177190
char = Character.from_tibiadata(content)
178191
self.assertEqual(char.name, "Steve")
179192
self.assertEqual(char.position, "CipSoft Member")
180193
self.assertEqual(char.account_information.position, "CipSoft Member")
181194

182-
def testCharacterSummonDeaths(self):
195+
def test_from_tibiadata_summon_deaths(self):
196+
"""Testing parsing a character with summon deaths"""
183197
content = self._load_resource(FILE_CHARACTER_TIBIADATA_DEATHS_SUMMON)
184198
char = Character.from_tibiadata(content)
185199
self.assertTrue(char.deaths)
@@ -188,15 +202,18 @@ def testCharacterSummonDeaths(self):
188202
self.assertTrue(summon_death.killers[2].summon, "a fire elemental")
189203
self.assertTrue(summon_death.killers[2].name, "Hasi Pupsi")
190204

191-
def testCharacterTibiaDataNotFound(self):
205+
def test_from_tibiadata_not_found(self):
206+
"""Testing parsing a not found character"""
192207
content = self._load_resource(FILE_CHARACTER_TIBIADATA_NOT_FOUND)
193208
char = Character.from_tibiadata(content)
194209
self.assertIsNone(char)
195210

196-
def testCharacterTibiaDataInvalidJson(self):
211+
def test_from_tibiadata_invalid_json(self):
212+
"""Testing parsing an invalid JSON string"""
197213
with self.assertRaises(InvalidContent):
198214
Character.from_tibiadata("<html><b>Not a json string</b></html>")
199215

200-
def testCharacterTibiaDataUnrelatedJson(self):
216+
def test_from_tibiadata_unrelated_json(self):
217+
"""Testing parsing an unrelated TibiaData section"""
201218
with self.assertRaises(InvalidContent):
202219
Character.from_tibiadata(self._load_resource(tests.tests_guild.FILE_GUILD_TIBIADATA))

tests/tests_client.py

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import aiohttp
44
import asynctest
55
from aioresponses import aioresponses
6-
from tests.tests_world import FILE_WORLD_FULL, FILE_WORLD_LIST
76

87
from tests.tests_character import FILE_CHARACTER_RESOURCE, FILE_CHARACTER_NOT_FOUND
98
from tests.tests_guild import FILE_GUILD_FULL, FILE_GUILD_LIST
@@ -12,6 +11,7 @@
1211
from tests.tests_kill_statistics import FILE_KILL_STATISTICS_FULL
1312
from tests.tests_news import FILE_NEWS_LIST, FILE_NEWS_ARTICLE
1413
from tests.tests_tibiapy import TestCommons
14+
from tests.tests_world import FILE_WORLD_FULL, FILE_WORLD_LIST
1515
from 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

Comments
 (0)