Repository navigation
Upgrades, fixes #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Upgrades, fixes #116
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ffac7b4
Update python version to 3.14
insolor afccace
Upgrade streamlit-gettext
insolor 6872e3f
Show language switcher if running locally
insolor 3c7828f
Prioritize Português (Brasil) if user langauge is pt_BR
insolor 8ccde8b
Fix ruff warnings
insolor 3fd8e56
Fix fixture usage in tests
insolor 24aee59
Test on Python from 3.12 through 3.14
insolor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,44 +1,89 @@ | ||
| from collections.abc import Callable | ||
| from __future__ import annotations | ||
|
|
||
| from pathlib import Path | ||
| from typing import TYPE_CHECKING | ||
| from unittest.mock import patch | ||
|
|
||
| import pytest | ||
| from streamlit.testing.v1 import AppTest | ||
|
|
||
| from package_build.i18n import set_preferred_languages | ||
| from package_build.models import DictInfoEntry, HookInfoEntry | ||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Iterator | ||
|
|
||
| project_root = Path(__file__).resolve().parent.parent | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| @patch("package_build.metadata.get_hook_metadata") | ||
| @patch("package_build.metadata.get_dict_metadata") | ||
| def apptest(get_dict_metadata: Callable, get_hook_metadata: Callable) -> AppTest: | ||
| get_hook_metadata.return_value = [ | ||
| HookInfoEntry( | ||
| df=0, | ||
| checksum=0, | ||
| lib="https://example.com/hook_0.1.0.dll", | ||
| config="https://example.com/hook_0.1.0.dll", | ||
| offsets="https://example.com/offsets/50.10_classic_win64.toml", | ||
| dfhooks="https://example.com/dfhooks.dll", | ||
| ), | ||
| ] | ||
|
|
||
| get_dict_metadata.return_value = [ | ||
| DictInfoEntry( | ||
| language="English", | ||
| code="en", | ||
| csv="https://example.com/en.csv", | ||
| font="https://example.com/cp437.png", | ||
| encoding="https://example.com/cp437.toml", | ||
| checksum=0, | ||
| ), | ||
| ] | ||
|
|
||
| app_path = project_root / "app.py" | ||
| return AppTest.from_file(app_path).run() | ||
| def apptest() -> Iterator[AppTest]: | ||
| with ( | ||
| patch("package_build.metadata.get_hook_metadata") as get_hook_metadata, | ||
| patch("package_build.metadata.get_dict_metadata") as get_dict_metadata, | ||
| ): | ||
| get_hook_metadata.return_value = [ | ||
| HookInfoEntry( | ||
| df=0, | ||
| checksum=0, | ||
| lib="https://example.com/hook_0.1.0.dll", | ||
| config="https://example.com/hook_0.1.0.dll", | ||
| offsets="https://example.com/offsets/50.10_classic_win64.toml", | ||
| dfhooks="https://example.com/dfhooks.dll", | ||
| ), | ||
| ] | ||
|
|
||
| get_dict_metadata.return_value = [ | ||
| DictInfoEntry( | ||
| language="English", | ||
| code="en", | ||
| csv="https://example.com/en.csv", | ||
| font="https://example.com/cp437.png", | ||
| encoding="https://example.com/cp437.toml", | ||
| checksum=0, | ||
| ), | ||
| DictInfoEntry( | ||
| language="Belarusian", | ||
| code="be", | ||
| csv="https://example.com/be.csv", | ||
| font="https://example.com/cp437.png", | ||
| encoding="https://example.com/cp437.toml", | ||
| checksum=0, | ||
| ), | ||
| DictInfoEntry( | ||
| language="Portuguese (Brazil)", | ||
| code="pt_BR", | ||
| csv="https://example.com/pt_BR.csv", | ||
| font="https://example.com/cp437.png", | ||
| encoding="https://example.com/cp437.toml", | ||
| checksum=0, | ||
| ), | ||
| ] | ||
|
|
||
| app_path = project_root / "app.py" | ||
| yield AppTest.from_file(app_path).run() | ||
|
|
||
|
|
||
| def test_smoketest(apptest: AppTest): | ||
| assert not apptest.exception, apptest.exception[0].stack_trace | ||
|
|
||
|
|
||
| def test_language_selector(apptest: AppTest): | ||
| language_selector = apptest.segmented_control[0] | ||
| assert "ru" in language_selector.options | ||
|
|
||
| try: | ||
| language_selector.set_value("ru").run() | ||
| assert not apptest.exception, apptest.exception[0].stack_trace | ||
| assert apptest.header[0].value == "Сборщик пакетов локализации для DF" | ||
| finally: | ||
| set_preferred_languages(None) | ||
|
|
||
|
|
||
| def test_brazilian_portuguese_is_prioritized(apptest: AppTest): | ||
| try: | ||
| apptest.segmented_control[0].set_value("pt_BR").run() | ||
| language_selector = apptest.selectbox[-1] | ||
| assert language_selector.value.code == "pt_BR" | ||
| finally: | ||
| set_preferred_languages(None) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.