-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HNT-281] Topic section ids match the topic id (#728)
* [HNT-281] change section ids to match topic ids * try dynamic feeds using create_model * enable pydantic mypy plugin * fix mypy errors * add -section suffix to topic sections add comments warning about topic section names * apply review feedback * Refactor section tests * fix comment
- Loading branch information
Showing
7 changed files
with
136 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Tests covering merino/curated_recommendations/localization.py""" | ||
|
||
from merino.curated_recommendations.localization import get_translation | ||
from merino.curated_recommendations.corpus_backends.protocol import ScheduledSurfaceId | ||
|
||
|
||
def test_get_translation_existing_translation(): | ||
"""Test that get_translation returns existing translations.""" | ||
result = get_translation(ScheduledSurfaceId.NEW_TAB_EN_US, "business", "Default") | ||
assert result == "Business" | ||
|
||
|
||
def test_get_translation_non_existing_locale(caplog): | ||
"""Test logs error and falls back to default when locale translations do not exist.""" | ||
result = get_translation(ScheduledSurfaceId.NEW_TAB_IT_IT, "business", "Default") | ||
assert result == "Default" | ||
|
||
errors = [r for r in caplog.records if r.levelname == "ERROR"] | ||
assert len(errors) == 1 | ||
assert "No translations found for surface" in errors[0].message | ||
|
||
|
||
def test_get_translation_non_existing_slug(caplog): | ||
"""Test logs error and falls back to default when the topic slug does not exist.""" | ||
result = get_translation(ScheduledSurfaceId.NEW_TAB_EN_US, "non_existing_slug", "Default") | ||
assert result == "Default" | ||
|
||
errors = [r for r in caplog.records if r.levelname == "ERROR"] | ||
assert len(errors) == 1 | ||
assert "Missing or empty translation for topic" in errors[0].message |