Skip to content

Commit

Permalink
Fixed game web link property
Browse files Browse the repository at this point in the history
It was filled wrong since i changed the url

Updated tests
  • Loading branch information
ScrappyCocco committed May 22, 2022
1 parent 2eb73c5 commit e9585b1
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion howlongtobeatpy/howlongtobeatpy/HTMLResultParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def handle_starttag(self, tag, attrs):
if att[0] == "href": # Get the game id from the link
start_pos = att[1].find('=') + 1
self.current_entry.game_id = att[1][start_pos:]
self.current_entry.game_web_link = self.base_game_url + str(self.current_entry.game_id)
self.current_entry.game_web_link = self.base_game_url + "?id=" + str(self.current_entry.game_id)

if tag == "img": # The tag <img> contains the img link for the game
for att in attrs:
Expand Down
2 changes: 1 addition & 1 deletion howlongtobeatpy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
long_description = fh.read()

setup(name='howlongtobeatpy',
version='0.1.21',
version='0.1.22',
packages=find_packages(exclude=['tests']),
description='A Python API for How Long to Beat',
long_description=long_description,
Expand Down
9 changes: 9 additions & 0 deletions howlongtobeatpy/tests/test_async_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ async def test_game_with_no_all_values(self):
self.assertEqual(None, best_result.gameplay_main_unit)
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(best_result.gameplay_main))

@async_test
async def test_game_link(self):
results = await HowLongToBeat().async_search("Battlefield 2142")
self.assertNotEqual(None, results, "Search Results are None")
best_result = TestNormalRequest.getMaxSimilarityElement(results)
self.assertNotEqual(None, best_result, "Search Result is None")
self.assertEqual("Battlefield 2142", best_result.game_name)
self.assertEqual("https://howlongtobeat.com/game?id=936", best_result.game_web_link)

@async_test
async def test_game_default_dlc_search(self):
results = await HowLongToBeat().async_search("Hearts of Stone")
Expand Down
7 changes: 7 additions & 0 deletions howlongtobeatpy/tests/test_async_request_by_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ async def test_game_with_no_all_values(self):
self.assertEqual(None, result.gameplay_main_unit)
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(result.gameplay_main))

@async_test
async def test_game_link(self):
result = await HowLongToBeat().async_search_from_id(936)
self.assertNotEqual(None, result, "Search Result is None")
self.assertEqual("Battlefield 2142", result.game_name)
self.assertEqual("https://howlongtobeat.com/game?id=936", result.game_web_link)

@async_test
async def test_no_real_game(self):
result = await HowLongToBeat().async_search_from_id(123)
Expand Down
8 changes: 8 additions & 0 deletions howlongtobeatpy/tests/test_normal_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def test_game_with_no_all_values(self):
self.assertEqual(None, best_result.gameplay_main_unit)
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(best_result.gameplay_main))

def test_game_link(self):
results = HowLongToBeat().search("Battlefield 2142")
self.assertNotEqual(None, results, "Search Results are None")
best_result = TestNormalRequest.getMaxSimilarityElement(results)
self.assertNotEqual(None, best_result, "Search Result is None")
self.assertEqual("Battlefield 2142", best_result.game_name)
self.assertEqual("https://howlongtobeat.com/game?id=936", best_result.game_web_link)

def test_game_default_dlc_search(self):
results = HowLongToBeat().search("Hearts of Stone")
self.assertEqual(1, len(results))
Expand Down
6 changes: 6 additions & 0 deletions howlongtobeatpy/tests/test_normal_request_by_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ def test_game_with_no_all_values(self):
self.assertEqual(None, result.gameplay_main_unit)
self.assertEqual(-1, TestNormalRequest.getSimpleNumber(result.gameplay_main))

def test_game_link(self):
result = HowLongToBeat().search_from_id(936)
self.assertNotEqual(None, result, "Search Result is None")
self.assertEqual("Battlefield 2142", result.game_name)
self.assertEqual("https://howlongtobeat.com/game?id=936", result.game_web_link)

def test_no_real_game(self):
result = HowLongToBeat().search_from_id(123)
self.assertEqual(None, result)
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sonar.organization=scrappycocco-github
sonar.projectKey=ScrappyCocco_HowLongToBeat-PythonAPI

sonar.projectName=HowLongToBeat-PythonAPI
sonar.projectVersion=0.1.21
sonar.projectVersion=0.1.22
sonar.python.version=3.6

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

0 comments on commit e9585b1

Please sign in to comment.