Compare commits

...
Author SHA1 Message Date
emilandDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> 3f223d5657 test: add unicode preservation and round-trip tests for save_vault_yaml
Add tests verifying allow_unicode=True behavior:
- test_save_preserves_unicode: non-ASCII content (Cyrillic, German
  umlaut, Chinese) is written as UTF-8, not \uXXXX escapes
- test_save_unicode_round_trip: saved unicode data loads back correctly

Also add CHANGELOG entry under [Unreleased] > Fixed.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-13 17:27:20 +02:00
emilandDevin <158243242+devin-ai-integration[bot]@users.noreply.github.com> ac0ce1c158 fix: pass allow_unicode=True in save_vault_yaml
Matches the pattern already used in infra's scripts/utils/secrets.py:save_yaml.
Prevents corruption of non-ASCII content in vault files.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-08-13 14:32:53 +02:00
3 changed files with 25 additions and 1 deletions
+5
View File
@@ -16,6 +16,11 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
### Fixed
- `save_vault_yaml`: pass `allow_unicode=True` to `yaml.dump` to prevent
corruption of non-ASCII vault content (matches infra's `save_yaml` pattern)
### Ci
- Add composite actions (setup-env, notify-failure, quality-checks) in `.gitea/actions/`
+1 -1
View File
@@ -102,7 +102,7 @@ def save_vault_yaml(path: Path, data: dict, vault_pass: Path | None = None) -> N
data: Data to serialize.
vault_pass: Path to the vault-password file (optional).
"""
plain = yaml.dump(data, default_flow_style=False, sort_keys=False)
plain = yaml.dump(data, default_flow_style=False, sort_keys=False, allow_unicode=True)
with open(path, "w", encoding="utf-8") as f:
f.write(plain)
if vault_pass is not None and vault_pass.exists():
+19
View File
@@ -75,6 +75,25 @@ class TestSaveVaultYaml:
content = f.read_text()
assert "key: value" in content
def test_save_preserves_unicode(self, tmp_path: Path) -> None:
"""allow_unicode=True writes UTF-8 instead of \\uXXXX escapes."""
f = tmp_path / "output.yml"
data = {"name": "Тест", "city": "München", "role": "管理员"}
save_vault_yaml(f, data)
content = f.read_text()
assert "Тест" in content
assert "München" in content
assert "管理员" in content
assert "\\u" not in content
def test_save_unicode_round_trip(self, tmp_path: Path) -> None:
"""Saved unicode data loads back correctly."""
f = tmp_path / "output.yml"
data = {"name": "Тест", "city": "München"}
save_vault_yaml(f, data)
loaded = load_vault_yaml(f)
assert loaded == data
def test_save_with_vault_pass_not_exists(self, tmp_path: Path) -> None:
f = tmp_path / "output.yml"
vp = tmp_path / "nonexistent"