mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-09-29 10:06:41 +00:00
Fix offline i18n tests: refresh semantics and complete Monitor catalogs
- Web docs test no longer passes the removed refresh argument. - i18n messages tests assert that --refresh keeps existing values and that only keys listed in --refresh-keys are re-translated. - Add the new Monitor keys to de, fr, it, pt, sk and sv. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e8a7ba6f47
commit
91e62b16e0
@@ -97,10 +97,23 @@ class I18nMessagesTests(unittest.TestCase):
|
||||
if text == "Two":
|
||||
raise RuntimeError("offline fixture failure")
|
||||
return "IT " + text
|
||||
# --refresh alone never replaces an existing translation.
|
||||
result, actual, calls, output, _ = self.run_generator(
|
||||
{"items": ["One", "Two", "Three"]}, {"items": ["Uno", "Due"]},
|
||||
"--refresh", "--save-every", "1", provider=provider)
|
||||
self.assertEqual(result, 0)
|
||||
self.assertEqual(actual, {"items": ["Uno", "Due", "IT Three"]})
|
||||
self.assertEqual(len(calls), 1)
|
||||
# Named keys are retranslated; a provider failure keeps the value.
|
||||
with tempfile.NamedTemporaryFile("w", suffix=".txt", delete=False) as keys:
|
||||
keys.write("items.0\nitems.1\n")
|
||||
try:
|
||||
result, actual, calls, output, _ = self.run_generator(
|
||||
{"items": ["One", "Two", "Three"]}, {"items": ["Uno", "Due"]},
|
||||
"--refresh", "--refresh-keys", keys.name, "--save-every", "1", provider=provider)
|
||||
finally:
|
||||
Path(keys.name).unlink()
|
||||
self.assertEqual(result, 0)
|
||||
self.assertEqual(actual, {"items": ["IT One", "Due", "IT Three"]})
|
||||
self.assertEqual(len(calls), 3)
|
||||
self.assertIn("1 translation failures", output)
|
||||
@@ -178,9 +191,10 @@ class I18nMessagesTests(unittest.TestCase):
|
||||
mock.patch.object(MODULE, "write_json", wraps=MODULE.write_json) as writer, \
|
||||
redirect_stderr(output), redirect_stdout(output):
|
||||
self.assertEqual(MODULE.main(), 1)
|
||||
# --refresh without --refresh-keys keeps the existing value.
|
||||
self.assertEqual(json.loads((root / "sk/common.json").read_text()),
|
||||
{"items": ["SK One" if options else "Human", "SK Two"]})
|
||||
self.assertEqual(provider.call_count, 2 if options else 1)
|
||||
{"items": ["Human", "SK Two"]})
|
||||
self.assertEqual(provider.call_count, 1)
|
||||
self.assertTrue(all(call.args[0].parent.name == "sk" for call in writer.call_args_list))
|
||||
for lang in ["en", "it", "de"]:
|
||||
self.assertEqual((root / lang / "common.json").read_bytes(), before[lang])
|
||||
|
||||
@@ -58,7 +58,7 @@ class WebDocsI18nTests(unittest.TestCase):
|
||||
def test_human_translation_is_not_pending(self):
|
||||
source = {"title": "Updates", "url": "https://example.com"}
|
||||
target = {"title": "Actualizaciones", "url": "https://example.com"}
|
||||
self.assertEqual(MODULE.pending_leaves(source, target, refresh=False), [])
|
||||
self.assertEqual(MODULE.pending_leaves(source, target), [])
|
||||
|
||||
def test_changed_source_text_is_pending_even_with_existing_translation(self):
|
||||
source = {"title": "Updated installation guidance"}
|
||||
@@ -67,7 +67,6 @@ class WebDocsI18nTests(unittest.TestCase):
|
||||
leaves = MODULE.pending_leaves(
|
||||
source,
|
||||
target,
|
||||
refresh=False,
|
||||
forced_tokens={token},
|
||||
)
|
||||
self.assertEqual([leaf.path for leaf in leaves], [("title",)])
|
||||
|
||||
Reference in New Issue
Block a user