refactor: replace hidden current-folder state with explicit Folder objects

This commit is contained in:
randogoth 2026-10-24 21:52:52 +03:00
parent a9a44ccb7e
commit 6fbd54c754
2 changed files with 59 additions and 46 deletions

View file

@ -207,7 +207,7 @@ def test_remove_saves_once(tree, monkeypatch):
o.add('a.mp3', '#lofi', '#snare', '#keep')
saves = []
save = o._OrvaniTag__save
monkeypatch.setattr(o, '_OrvaniTag__save', lambda: saves.append(1) or save())
monkeypatch.setattr(o, '_OrvaniTag__save', lambda folder: saves.append(1) or save(folder))
o.remove('a.mp3', '#lofi', '#snare')
assert len(saves) == 1
assert lines(tree) == ['a.mp3 --- #keep']
@ -294,3 +294,12 @@ def test_clean_with_a_file_path_cleans_its_folder(tree):
(tree / 'b.mp3').unlink()
assert o.clean('a.mp3', False) == 1
assert lines(tree) == ['a.mp3 --- #lofi']
def test_broken_context_file_only_affects_its_own_folder(tree):
(tree / orvani.CONTEXT_FILE).write_text('broken line\n')
o = OrvaniTag()
o.add('sub/d.txt', '#doc')
assert lines(tree / 'sub') == ['d.txt --- #doc']
with pytest.raises(FormatError):
o.add('a.mp3', '#lofi')