From 2319a6bf3c32407d387c45a522f20e23b7ba885f Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Sun, 3 May 2026 16:09:38 +0200 Subject: 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 --- tests/test_taxonomy.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'tests/test_taxonomy.py') 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 == {} -- cgit v1.2.3