From 5e9d3330b500aa277b1b9eab618db2c9804c7c48 Mon Sep 17 00:00:00 2001 From: Valentin Porchet Date: Sun, 15 Sep 2024 20:39:07 +0200 Subject: [PATCH] fix: fixed issue with missing chapter content on Juno hero page (#195) * fix: fixed issue with missing chapter content on Juno hero page * fixed test for consistency --- app/config.py | 2 +- app/parsers/hero_parser.py | 6 +++--- pyproject.toml | 2 +- tests/commands/test_check_and_update_cache.py | 16 ++++++++-------- tests/common/test_cache_manager.py | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/config.py b/app/config.py index 653c7c46..946ba332 100644 --- a/app/config.py +++ b/app/config.py @@ -137,7 +137,7 @@ class Settings(BaseSettings): home_path: str = "/" # Route for Overwatch heroes pages - heroes_path: str = "/heroes" + heroes_path: str = "/heroes/" # Route for players career pages career_path: str = "/career" diff --git a/app/parsers/hero_parser.py b/app/parsers/hero_parser.py index 5ede0aa3..05188364 100644 --- a/app/parsers/hero_parser.py +++ b/app/parsers/hero_parser.py @@ -28,7 +28,7 @@ def __init__(self, **kwargs): self.locale = kwargs.get("locale") or Locale.ENGLISH_US def get_blizzard_url(self, **kwargs) -> str: - return f"{super().get_blizzard_url(**kwargs)}/{kwargs.get('hero_key')}" + return f"{super().get_blizzard_url(**kwargs)}{kwargs.get('hero_key')}/" def parse_data(self) -> dict: # We must check if we have the expected section for hero. If not, @@ -66,7 +66,7 @@ def __get_summary(self, overview_section: Tag) -> dict: header_section.find("p", slot="description").get_text().strip() ), "role": get_role_from_icon_url(extra_list_items[0].find("image")["href"]), - "location": extra_list_items[1].get_text(), + "location": extra_list_items[1].get_text().strip(), "birthday": birthday, "age": age, } @@ -163,7 +163,7 @@ def __get_story_chapters(accordion: Tag) -> list[dict]: " ".join( [ paragraph.get_text() - for paragraph in content_container.find_all("p") + for paragraph in content_container.find_all(["p", "pr"]) ], ).strip() ) diff --git a/pyproject.toml b/pyproject.toml index 9226470f..e7e90130 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "overfast-api" -version = "2.37.0" +version = "2.37.1" description = "Overwatch API giving data about heroes, maps, and players statistics." license = {file = "LICENSE"} authors = [ diff --git a/tests/commands/test_check_and_update_cache.py b/tests/commands/test_check_and_update_cache.py index b12411c2..4751e746 100644 --- a/tests/commands/test_check_and_update_cache.py +++ b/tests/commands/test_check_and_update_cache.py @@ -47,7 +47,7 @@ def test_check_and_update_gamemodes_cache_to_update( settings.expired_cache_refresh_limit + 30, ) cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit + 5, ) @@ -89,7 +89,7 @@ def test_check_and_update_specific_hero_to_update( hero_json_data: dict, ): ana_cache_key = ( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana" + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/" ) # Add some data (to update and not to update) @@ -163,7 +163,7 @@ def test_check_and_update_cache_no_update(cache_manager: CacheManager, locale: s settings.expired_cache_refresh_limit + 30, ) cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit + 5, ) @@ -202,7 +202,7 @@ def test_check_and_update_specific_player_to_update( settings.expired_cache_refresh_limit - 5, ) cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit + 5, ) @@ -254,7 +254,7 @@ def test_check_and_update_player_stats_summary_to_update( settings.expired_cache_refresh_limit - 5, ) cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit + 5, ) @@ -297,7 +297,7 @@ def test_check_and_update_player_stats_summary_to_update( def test_check_internal_error_from_blizzard(cache_manager: CacheManager, locale: str): # Add some data (to update and not to update) cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit - 5, ) @@ -325,7 +325,7 @@ def test_check_internal_error_from_blizzard(cache_manager: CacheManager, locale: def test_check_timeout_from_blizzard(cache_manager: CacheManager, locale: str): # Add some data (to update and not to update) cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit - 5, ) @@ -475,7 +475,7 @@ def test_check_and_update_namecard_to_update( # Add some data which doesn't need update cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit + 5, ) diff --git a/tests/common/test_cache_manager.py b/tests/common/test_cache_manager.py index 0c7e11f7..908d30e6 100644 --- a/tests/common/test_cache_manager.py +++ b/tests/common/test_cache_manager.py @@ -168,7 +168,7 @@ def test_get_soon_expired_cache_keys( is_redis_server_up, ): cache_manager.update_parser_cache( - f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}/ana", + f"HeroParser-{settings.blizzard_host}/{locale}{settings.heroes_path}ana/", {}, settings.expired_cache_refresh_limit + 5, )