Public Access
DEVX-7: fix: make all warnings into errors across devx tools
This commit is contained in:
@@ -67,7 +67,7 @@ class TestCheckTranslationSet:
|
||||
trans_file.write_text(json.dumps({"Used": {"en": "Used"}, "Dead": {"en": "Dead"}}))
|
||||
|
||||
result = check_translations.check_translation_set("test", src_dir, trans_file)
|
||||
assert any("Dead key" in w for w in result.warnings)
|
||||
assert any("Dead key" in e for e in result.errors)
|
||||
|
||||
def test_missing_language(self, tmp_path: Path) -> None:
|
||||
src_dir = tmp_path / "src"
|
||||
@@ -77,7 +77,7 @@ class TestCheckTranslationSet:
|
||||
trans_file.write_text(json.dumps({"Hello": {"en": "Hello"}}))
|
||||
|
||||
result = check_translations.check_translation_set("test", src_dir, trans_file)
|
||||
assert any("Missing languages" in w for w in result.warnings)
|
||||
assert any("Missing languages" in e for e in result.errors)
|
||||
|
||||
def test_missing_translations_file(self, tmp_path: Path) -> None:
|
||||
src_dir = tmp_path / "src"
|
||||
@@ -108,23 +108,19 @@ class TestMain:
|
||||
result = runner.invoke(check_translations.main, [])
|
||||
assert result.exit_code == 0
|
||||
|
||||
def test_strict_fails_on_warnings(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""--strict should fail if there are missing language warnings."""
|
||||
warn_result = check_translations.TranslationCheckResult(
|
||||
def test_errors_fail(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Errors should cause exit code 1."""
|
||||
error_result = check_translations.TranslationCheckResult(
|
||||
name="devx",
|
||||
src_dir=Path("/tmp"),
|
||||
trans_file=Path("/tmp/t.json"),
|
||||
used_keys={"a"},
|
||||
defined_keys={"a"},
|
||||
warnings=["Dead key: 'bar'"],
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
check_translations,
|
||||
"check_translation_set",
|
||||
lambda name, src, trans: warn_result,
|
||||
errors=["Dead key: 'bar'"],
|
||||
)
|
||||
monkeypatch.setattr(check_translations, "check_translation_set", lambda name, src, trans: error_result)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(check_translations.main, ["--strict"])
|
||||
result = runner.invoke(check_translations.main, [])
|
||||
assert result.exit_code == 1
|
||||
|
||||
def test_fails_on_errors(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
@@ -311,26 +307,25 @@ class TestCollectKeys:
|
||||
assert "in_progress" in keys
|
||||
|
||||
|
||||
class TestMainWarnings:
|
||||
def test_passes_with_warnings(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Should pass with exit code 0 and 'PASS with warnings' message."""
|
||||
warn_result = check_translations.TranslationCheckResult(
|
||||
class TestMainCleanPass:
|
||||
def test_passes_clean(self, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Should pass with exit code 0 and 'PASS:' message when no errors."""
|
||||
ok_result = check_translations.TranslationCheckResult(
|
||||
name="devx",
|
||||
src_dir=Path("/tmp"),
|
||||
trans_file=Path("/tmp/t.json"),
|
||||
used_keys={"a"},
|
||||
defined_keys={"a"},
|
||||
warnings=["Dead key: 'bar'"],
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
check_translations,
|
||||
"check_translation_set",
|
||||
lambda name, src, trans: warn_result,
|
||||
lambda name, src, trans: ok_result,
|
||||
)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(check_translations.main, [])
|
||||
assert result.exit_code == 0
|
||||
assert "PASS with warnings" in result.output
|
||||
assert "PASS:" in result.output
|
||||
|
||||
|
||||
class TestI18nProjectTranslations:
|
||||
|
||||
Reference in New Issue
Block a user