Skip to content

Commit e9585b1

Browse files
committed
Fixed game web link property
It was filled wrong since i changed the url Updated tests
1 parent 2eb73c5 commit e9585b1

File tree

7 files changed

+33
-3
lines changed

7 files changed

+33
-3
lines changed

howlongtobeatpy/howlongtobeatpy/HTMLResultParser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def handle_starttag(self, tag, attrs):
6161
if att[0] == "href": # Get the game id from the link
6262
start_pos = att[1].find('=') + 1
6363
self.current_entry.game_id = att[1][start_pos:]
64-
self.current_entry.game_web_link = self.base_game_url + str(self.current_entry.game_id)
64+
self.current_entry.game_web_link = self.base_game_url + "?id=" + str(self.current_entry.game_id)
6565

6666
if tag == "img": # The tag <img> contains the img link for the game
6767
for att in attrs:

howlongtobeatpy/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
long_description = fh.read()
55

66
setup(name='howlongtobeatpy',
7-
version='0.1.21',
7+
version='0.1.22',
88
packages=find_packages(exclude=['tests']),
99
description='A Python API for How Long to Beat',
1010
long_description=long_description,

howlongtobeatpy/tests/test_async_request.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ async def test_game_with_no_all_values(self):
6464
self.assertEqual(None, best_result.gameplay_main_unit)
6565
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(best_result.gameplay_main))
6666

67+
@async_test
68+
async def test_game_link(self):
69+
results = await HowLongToBeat().async_search("Battlefield 2142")
70+
self.assertNotEqual(None, results, "Search Results are None")
71+
best_result = TestNormalRequest.getMaxSimilarityElement(results)
72+
self.assertNotEqual(None, best_result, "Search Result is None")
73+
self.assertEqual("Battlefield 2142", best_result.game_name)
74+
self.assertEqual("https://howlongtobeat.com/game?id=936", best_result.game_web_link)
75+
6776
@async_test
6877
async def test_game_default_dlc_search(self):
6978
results = await HowLongToBeat().async_search("Hearts of Stone")

howlongtobeatpy/tests/test_async_request_by_id.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ async def test_game_with_no_all_values(self):
5757
self.assertEqual(None, result.gameplay_main_unit)
5858
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(result.gameplay_main))
5959

60+
@async_test
61+
async def test_game_link(self):
62+
result = await HowLongToBeat().async_search_from_id(936)
63+
self.assertNotEqual(None, result, "Search Result is None")
64+
self.assertEqual("Battlefield 2142", result.game_name)
65+
self.assertEqual("https://howlongtobeat.com/game?id=936", result.game_web_link)
66+
6067
@async_test
6168
async def test_no_real_game(self):
6269
result = await HowLongToBeat().async_search_from_id(123)

howlongtobeatpy/tests/test_normal_request.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ def test_game_with_no_all_values(self):
8181
self.assertEqual(None, best_result.gameplay_main_unit)
8282
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(best_result.gameplay_main))
8383

84+
def test_game_link(self):
85+
results = HowLongToBeat().search("Battlefield 2142")
86+
self.assertNotEqual(None, results, "Search Results are None")
87+
best_result = TestNormalRequest.getMaxSimilarityElement(results)
88+
self.assertNotEqual(None, best_result, "Search Result is None")
89+
self.assertEqual("Battlefield 2142", best_result.game_name)
90+
self.assertEqual("https://howlongtobeat.com/game?id=936", best_result.game_web_link)
91+
8492
def test_game_default_dlc_search(self):
8593
results = HowLongToBeat().search("Hearts of Stone")
8694
self.assertEqual(1, len(results))

howlongtobeatpy/tests/test_normal_request_by_id.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def test_game_with_no_all_values(self):
5151
self.assertEqual(None, result.gameplay_main_unit)
5252
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(result.gameplay_main))
5353

54+
def test_game_link(self):
55+
result = HowLongToBeat().search_from_id(936)
56+
self.assertNotEqual(None, result, "Search Result is None")
57+
self.assertEqual("Battlefield 2142", result.game_name)
58+
self.assertEqual("https://howlongtobeat.com/game?id=936", result.game_web_link)
59+
5460
def test_no_real_game(self):
5561
result = HowLongToBeat().search_from_id(123)
5662
self.assertEqual(None, result)

sonar-project.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ sonar.organization=scrappycocco-github
22
sonar.projectKey=ScrappyCocco_HowLongToBeat-PythonAPI
33

44
sonar.projectName=HowLongToBeat-PythonAPI
5-
sonar.projectVersion=0.1.21
5+
sonar.projectVersion=0.1.22
66
sonar.python.version=3.6
77

88
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.

0 commit comments

Comments
 (0)