Skip to content

Commit ecab741

Browse files
committed
Renaming test cases and updated changelog
1 parent 12ba0ac commit ecab741

File tree

7 files changed

+111
-60
lines changed

7 files changed

+111
-60
lines changed

CHANGELOG.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Changelog
66
Due to this library relying on external content, older versions are not guaranteed to work.
77
Try to always use the latest version.
88

9+
10+
.. _v2.2.0:
11+
12+
2.2.0 (2019-08-08)
13+
==================
14+
15+
- Added support for account badges and character titles.
16+
917
.. _v2.1.0:
1018

1119
2.1.0 (2019-06-17)

tests/tests_house.py

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def test_house_parse_status_rented(self):
7070
self.assertEqual(house.owner, "Thorcen")
7171
self.assertIsInstance(house.paid_until, datetime.datetime)
7272

73-
def testHouseStatusWithBids(self):
73+
def test_house_parse_status_with_bids(self):
74+
"""Testing parsing a house status with bids"""
7475
house = House("Name")
7576
content = self._load_resource(FILE_HOUSE_STATUS_WITH_BIDS)
7677
house._parse_status(content)
@@ -80,25 +81,29 @@ def testHouseStatusWithBids(self):
8081
self.assertEqual(house.highest_bidder, "King of Bosnia")
8182
self.assertIsInstance(house.auction_end, datetime.datetime)
8283

83-
def testHouseStatusWithoutBids(self):
84+
def test_house_parse_status_without_bids(self):
85+
"""Testing parsing the status of a house with no bids"""
8486
house = House("Name")
8587
content = self._load_resource(FILE_HOUSE_STATUS_NO_BIDS)
8688
house._parse_status(content)
8789
self.assertEqual(house.status, HouseStatus.AUCTIONED)
8890
self.assertIsNone(house.auction_end)
8991

90-
def testHouseNotFound(self):
92+
def test_house_from_content_not_found(self):
93+
"""Testing parsing a house that doesn't exist"""
9194
content = self._load_resource(FILE_HOUSE_NOT_FOUND)
9295
house = House.from_content(content)
9396

9497
self.assertIsNone(house)
9598

96-
def testHouseUnrelated(self):
99+
def test_house_from_content_unrelated(self):
100+
"""Testing parsing an unrelated section"""
97101
content = self._load_resource(self.FILE_UNRELATED_SECTION)
98102
with self.assertRaises(InvalidContent):
99103
House.from_content(content)
100104

101-
def testHouseList(self):
105+
def test_listed_house_from_content(self):
106+
"""Testing parsing the house list of a world and city"""
102107
content = self._load_resource(FILE_HOUSE_LIST)
103108
houses = ListedHouse.list_from_content(content)
104109

@@ -113,24 +118,28 @@ def testHouseList(self):
113118

114119
self.assertEqual(houses[25].status, HouseStatus.RENTED)
115120

116-
def testHouseListEmpty(self):
121+
def test_listed_house_from_content_empty(self):
122+
"""Testing parsing an empty house list"""
117123
content = self._load_resource(FILE_HOUSE_LIST_EMPTY)
118124
houses = ListedHouse.list_from_content(content)
119125

120126
self.assertEqual(len(houses), 0)
121127

122-
def testHouseListNotFound(self):
128+
def test_listed_house_from_content_not_found(self):
129+
"""Testing parsing an empty house list"""
123130
content = self._load_resource(FILE_HOUSE_NOT_FOUND)
124131
houses = ListedHouse.list_from_content(content)
125132

126133
self.assertIsNone(houses)
127134

128-
def testHouseListUnrelated(self):
135+
def test_listed_house_from_content_unrelated(self):
136+
"""Testing parsing an unrelated section"""
129137
content = self._load_resource(self.FILE_UNRELATED_SECTION)
130138
with self.assertRaises(InvalidContent):
131139
ListedHouse.list_from_content(content)
132140

133-
def testHouseTibiaData(self):
141+
def test_house_from_tibiadata(self):
142+
"""Testing parsing a house from TibiaData"""
134143
content = self._load_resource(FILE_HOUSE_TIBIADATA)
135144
house = House.from_tibiadata(content)
136145

@@ -142,22 +151,26 @@ def testHouseTibiaData(self):
142151
self.assertEqual(house.status, HouseStatus.AUCTIONED)
143152
self.assertIsNone(house.owner)
144153

145-
def testHouseTibiaDataNotFound(self):
154+
def test_house_from_tibiadata_not_found(self):
155+
"""Testing parsing a house that doesn't exist"""
146156
content = self._load_resource(FILE_HOUSE_TIBIADATA_NOT_FOUND)
147157
house = House.from_tibiadata(content)
148158

149159
self.assertIsNone(house)
150160

151-
def testHouseTibiaDataInvalid(self):
161+
def test_house_from_tibiadata_invalid_json(self):
162+
"""Testing parsing an invalid json"""
152163
with self.assertRaises(InvalidContent):
153164
House.from_tibiadata("<p>Not json</p>")
154165

155-
def testGuildTibiaDataUnrelated(self):
166+
def test_house_from_tibiadata_unrelated(self):
167+
"""Testing parsing an unrelated section"""
156168
content = self._load_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA)
157169
with self.assertRaises(InvalidContent):
158170
House.from_tibiadata(content)
159171

160-
def testHouseTibiaDataList(self):
172+
def test_listed_house_list_from_tibiadata(self):
173+
"""Testing parsing a house list from TibiaData"""
161174
content = self._load_resource(FILE_HOUSE_TIBIADATA_LIST)
162175
houses = ListedHouse.list_from_tibiadata(content)
163176

@@ -170,17 +183,20 @@ def testHouseTibiaDataList(self):
170183
self.assertIsInstance(houses[0].id, int)
171184
self.assertIsNotNone(ListedHouse.get_list_url_tibiadata(houses[0].world, houses[0].town))
172185

173-
def testHouseTibiaDataListNotFound(self):
186+
def test_listed_house_list_from_tibiadata_not_found(self):
187+
"""Testing parsing a list of a world that doesn't exist"""
174188
content = self._load_resource(FILE_HOUSE_TIBIADATA_LIST_NOT_FOUND)
175189
houses = ListedHouse.list_from_tibiadata(content)
176190

177191
self.assertIsInstance(houses, list)
178192
self.assertEqual(len(houses), 0)
179193

180-
def testHouseTibiaDataListInvalidJson(self):
194+
def test_listed_house_list_from_tibiadata_invalid_json(self):
195+
"""Testing parsing an invalid json"""
181196
with self.assertRaises(InvalidContent):
182197
ListedHouse.list_from_tibiadata("nope")
183198

184-
def testHouseTibiaDataListUnrelated(self):
199+
def test_listed_house_list_from_tibiadata_unrelated_section(self):
200+
"""Testing parsing an unrelated section"""
185201
with self.assertRaises(InvalidContent):
186202
ListedHouse.list_from_tibiadata(self._load_resource(tests.tests_character.FILE_CHARACTER_TIBIADATA))

tests/tests_kill_statistics.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
class TestHighscores(TestCommons, unittest.TestCase):
1111
# region Tibia.com Tests
12-
def testKillStatistics(self):
12+
def test_kill_statistics_from_content(self):
13+
"""Testing parsing kill statistics"""
1314
content = self._load_resource(FILE_KILL_STATISTICS_FULL)
1415
kill_statistics = KillStatistics.from_content(content)
1516

@@ -25,13 +26,15 @@ def testKillStatistics(self):
2526
self.assertEqual(kill_statistics.players.last_week_killed, 7)
2627
self.assertEqual(kill_statistics.players.last_week_killed, kill_statistics.players.last_week_players_killed)
2728

28-
def testKillStatisticsEmpty(self):
29+
def test_kill_statistics_from_content_empty(self):
30+
"""Testing parsing empty kill statistics"""
2931
content = self._load_resource(FILE_KILL_STATISTICS_EMPTY)
3032
kill_statistics = KillStatistics.from_content(content)
3133

3234
self.assertIsNone(kill_statistics)
3335

34-
def testKillStatisticsUnrelated(self):
36+
def test_kill_statistics_from_content_unrelated_section(self):
37+
"""Testing parsing an unrelated section"""
3538
content = self._load_resource(self.FILE_UNRELATED_SECTION)
3639
with self.assertRaises(InvalidContent):
3740
KillStatistics.from_content(content)

tests/tests_news.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
class TestNews(TestCommons, unittest.TestCase):
1616
# region Tibia.com Tests
17-
def testNewsList(self):
17+
def test_listed_news_from_content(self):
18+
"""Testing parsing news"""
1819
content = self._load_resource(FILE_NEWS_LIST)
1920
news_list = ListedNews.list_from_content(content)
2021
self.assertGreater(len(news_list), 0)
@@ -28,27 +29,32 @@ def testNewsList(self):
2829
self.assertIsNotNone(latest_news.url)
2930
self.assertEqual(latest_news.url, ListedNews.get_url(latest_news.id))
3031

31-
def testNewsListEmpty(self):
32+
def test_listed_news_from_content_empty(self):
33+
"""Testing parsing a news article that doesn't exist"""
3234
content = self._load_resource(FILE_NEWS_LIST_EMPTY)
3335
news_list = ListedNews.list_from_content(content)
3436
self.assertEqual(len(news_list), 0)
3537

36-
def testNewsListUnrelated(self):
38+
def test_listed_news_from_content_unrelated(self):
39+
"""Testing parsing an unrelated section"""
3740
content = self._load_resource(self.FILE_UNRELATED_SECTION)
3841
with self.assertRaises(InvalidContent):
3942
ListedNews.list_from_content(content)
4043

41-
def testNewsEmpty(self):
44+
def test_news_from_content_empty(self):
45+
"""Testing parsing an empty news article"""
4246
content = self._load_resource(FILE_NEWS_EMPTY)
4347
news = News.from_content(content)
4448
self.assertIsNone(news)
4549

46-
def testNewsUnrelated(self):
50+
def test_news_from_content_unrelated(self):
51+
"""Testing parsing an unrelated section"""
4752
content = self._load_resource(self.FILE_UNRELATED_SECTION)
4853
with self.assertRaises(InvalidContent):
4954
News.from_content(content)
5055

51-
def testNewsTicker(self):
56+
def test_news_from_content_ticker(self):
57+
"""Testing parsing a news ticker"""
5258
content = self._load_resource(FILE_NEWS_TICKER)
5359
news = News.from_content(content)
5460

@@ -58,7 +64,8 @@ def testNewsTicker(self):
5864
self.assertEqual(news.title, "News Ticker")
5965
self.assertIsNone(news.thread_id)
6066

61-
def testNewsArticle(self):
67+
def test_news_from_content_article(self):
68+
"""Testing parsing an article"""
6269
content = self._load_resource(FILE_NEWS_ARTICLE)
6370
news = News.from_content(content)
6471

tests/tests_utils.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import unittest
33

44
import tibiapy
5-
65
from tests.tests_tibiapy import TestCommons
76
from tibiapy import enums, utils
87
from tibiapy.utils import parse_integer, parse_tibia_money
@@ -35,7 +34,8 @@
3534

3635

3736
class TestUtils(TestCommons, unittest.TestCase):
38-
def testSerializableGetItem(self):
37+
def test_serializable_get_item(self):
38+
"""Testing the muliple ways to use __get__ for Serializable"""
3939
# Class inherits from Serializable
4040
world = tibiapy.World("Calmera")
4141

@@ -57,7 +57,7 @@ def testSerializableGetItem(self):
5757
with self.assertRaises(KeyError):
5858
world["custom"] = "custom value"
5959

60-
def testTibiaDateTime(self):
60+
def test_parse_tibia_datetime(self):
6161
time = utils.parse_tibia_datetime(TIBIA_DATETIME_CEST)
6262
self.assertIsInstance(time, datetime.datetime)
6363
self.assertEqual(time.month, 7)
@@ -76,33 +76,33 @@ def testTibiaDateTime(self):
7676
self.assertEqual(time.minute, 13)
7777
self.assertEqual(time.second, 32)
7878

79-
def testTibiaDateInvalidTimezone(self):
79+
def test_parse_tibia_datetime_invalid_timezone(self):
8080
time = utils.parse_tibia_datetime(TIBIA_DATETIME_PST)
8181
self.assertIsNone(time)
8282

83-
def testTibiaDateTimeInvalid(self):
83+
def test_parse_tibia_datetime_invalid_datetime(self):
8484
time = utils.parse_tibia_datetime(TIBIA_DATETIME_INVALID)
8585
self.assertIsNone(time)
8686

87-
def testTibiaDate(self):
87+
def test_parse_tibia_date(self):
8888
date = utils.parse_tibia_date(TIBIA_DATE)
8989
self.assertIsInstance(date, datetime.date)
9090
self.assertEqual(date.month, 6)
9191
self.assertEqual(date.day, 20)
9292
self.assertEqual(date.year, 2018)
9393

94-
def testTibiaFullDate(self):
94+
def test_parse_tibia_date_full(self):
9595
date = utils.parse_tibia_full_date(TIBIA_FULL_DATE)
9696
self.assertIsInstance(date, datetime.date)
9797
self.assertEqual(date.month, 7)
9898
self.assertEqual(date.day, 23)
9999
self.assertEqual(date.year, 2015)
100100

101-
def testTibiaDateInvalid(self):
101+
def test_parse_tibia_date_invalid(self):
102102
date = utils.parse_tibia_date(TIBIA_DATETIME_INVALID)
103103
self.assertIsNone(date)
104104

105-
def testTibiaDataDatetime(self):
105+
def test_parse_tibia_datetime_from_datetime(self):
106106
date = utils.parse_tibiadata_datetime(TIBIADATA_DATETIME_CET)
107107
self.assertIsInstance(date, datetime.datetime)
108108

@@ -117,7 +117,7 @@ def testTibiaDataDatetime(self):
117117
date = utils.parse_tibiadata_datetime(TIBIA_DATE)
118118
self.assertIsNone(date)
119119

120-
def testTryDate(self):
120+
def test_try_date(self):
121121
date = utils.try_date(datetime.datetime.now())
122122
self.assertIsInstance(date, datetime.date)
123123

@@ -134,7 +134,7 @@ def testTryDate(self):
134134
date = utils.try_date(TIBIADATA_DATE)
135135
self.assertIsInstance(date, datetime.date)
136136

137-
def testTryDateTime(self):
137+
def test_try_date_time(self):
138138
date_time = utils.try_datetime(datetime.datetime.now())
139139
self.assertIsInstance(date_time, datetime.datetime)
140140

@@ -144,34 +144,34 @@ def testTryDateTime(self):
144144
date_time = utils.try_datetime(TIBIADATA_DATETIME_CET)
145145
self.assertIsInstance(date_time, datetime.datetime)
146146

147-
def testParseNumberWords(self):
147+
def test_parse_number_words(self):
148148
self.assertEqual(utils.parse_number_words("one"), 1)
149149
self.assertEqual(utils.parse_number_words("no"), 0)
150150
self.assertEqual(utils.parse_number_words("..."), 0)
151151
self.assertEqual(utils.parse_number_words("twenty-one"), 21)
152152
self.assertEqual(utils.parse_number_words("one hundred two"), 102)
153153
self.assertEqual(utils.parse_number_words("two thousand forty five"), 2045)
154154

155-
def testTryEnum(self):
155+
def test_try_enum(self):
156156
self.assertEqual(utils.try_enum(enums.Sex, "male"), enums.Sex.MALE)
157157
self.assertEqual(utils.try_enum(enums.TransferType, "", enums.TransferType.REGULAR), enums.TransferType.REGULAR)
158158
self.assertEqual(utils.try_enum(enums.WorldLocation, enums.WorldLocation.EUROPE), enums.WorldLocation.EUROPE)
159159

160-
def testEnumStr(self):
160+
def test_enum_str(self):
161161
self.assertEqual(str(enums.Sex.MALE), enums.Sex.MALE.value)
162162
self.assertEqual(enums.VocationFilter.from_name("royal paladin"), enums.VocationFilter.PALADINS)
163163
self.assertEqual(enums.VocationFilter.from_name("unknown"), enums.VocationFilter.ALL)
164164
self.assertIsNone(enums.VocationFilter.from_name("unknown", False))
165165

166-
def testParseTibiaMoney(self):
166+
def test_parse_tibia_money(self):
167167
self.assertEqual(1000, parse_tibia_money("1k"))
168168
self.assertEqual(5000000, parse_tibia_money("5kk"))
169169
self.assertEqual(2500, parse_tibia_money("2.5k"))
170170
self.assertEqual(50, parse_tibia_money("50"))
171171
with self.assertRaises(ValueError):
172172
parse_tibia_money("abc")
173173

174-
def testParseInteger(self):
174+
def test_parse_integer(self):
175175
self.assertEqual(1450, parse_integer("1.450"))
176176
self.assertEqual(1110, parse_integer("1,110"))
177177
self.assertEqual(15, parse_integer("15"))

0 commit comments

Comments
 (0)