summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-05-03 16:09:38 +0200
committerDanilo M. <danix@danix.xyz>2026-05-03 16:09:38 +0200
commit2319a6bf3c32407d387c45a522f20e23b7ba885f (patch)
tree8d7186e5487ff2c01b5069a3f4630dce2c7d1b3a /tests
parent365b911ba1288ccfb428602ba765750ad9d0a139 (diff)
downloadpublisher-2319a6bf3c32407d387c45a522f20e23b7ba885f.tar.gz
publisher-2319a6bf3c32407d387c45a522f20e23b7ba885f.zip
feat: propagate tag renames to articles after taxonomy save
After saving TaxonomyView, detect renamed IT/EN tags by comparing old and new it_to_en dicts, then rewrite frontmatter of affected articles. Status bar shows count of updated articles. Taxonomy save failure aborts propagation. Adds pytest-qt and four unit tests for _detect_renames. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_taxonomy.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/test_taxonomy.py b/tests/test_taxonomy.py
index a10531b..b5f48e9 100644
--- a/tests/test_taxonomy.py
+++ b/tests/test_taxonomy.py
@@ -2,6 +2,7 @@
import pytest
from pathlib import Path
from core.taxonomy import TaxonomyModel, load_taxonomy, save_taxonomy
+from ui.taxonomy_view import TaxonomyView
def _write_pair(tmp_path, it_lines, en_lines):
it_file = tmp_path / "tags-it.txt"
@@ -41,3 +42,35 @@ def test_save_taxonomy_sorted(tmp_path):
save_taxonomy(model, it_f, en_f)
lines = it_f.read_text().splitlines()
assert lines == sorted(lines)
+
+
+def test_detect_renames_en_change(qtbot):
+ old = {"linux": "linux", "vita": "life"}
+ new = {"linux": "linux", "vita": "living"}
+ it_r, en_r = TaxonomyView._detect_renames(old, new)
+ assert it_r == {}
+ assert en_r == {"life": "living"}
+
+
+def test_detect_renames_it_change(qtbot):
+ old = {"linux": "linux", "vita": "life"}
+ new = {"linux": "linux", "living": "life"}
+ it_r, en_r = TaxonomyView._detect_renames(old, new)
+ assert it_r == {"vita": "living"}
+ assert en_r == {}
+
+
+def test_detect_renames_no_change(qtbot):
+ old = {"linux": "linux"}
+ new = {"linux": "linux"}
+ it_r, en_r = TaxonomyView._detect_renames(old, new)
+ assert it_r == {}
+ assert en_r == {}
+
+
+def test_detect_renames_addition_not_rename(qtbot):
+ old = {"linux": "linux"}
+ new = {"linux": "linux", "vita": "life"}
+ it_r, en_r = TaxonomyView._detect_renames(old, new)
+ assert it_r == {}
+ assert en_r == {}