release: prepare 0.4.0 installer and finalize content protection checks

This commit is contained in:
2026-10-29 21:53:44 +08:00
parent a40a6cd749
commit a09fa8b885
9 changed files with 82 additions and 21 deletions
+7 -2
View File
@@ -21,7 +21,7 @@ def test_comparison_dialog_uses_selected_disk_chunk(qt_application, tmp_path):
assert save_conflict.resolve_save_conflict(None, tmp_path / 'note.md', 'a\nlocal\n', 'a\nremote\n', 'a\nbase\n') == 'a\nremote\n'
@pytest.mark.parametrize('decision', ['cancel', 'merge', 'race', 'deleted'])
@pytest.mark.parametrize('decision', ['cancel', 'merge', 'race', 'deleted', 'same_metadata'])
def test_editor_conflict_protects_both_versions(qt_application, tmp_path, monkeypatch, decision):
settings = QSettings(str(tmp_path / 'settings.ini'), QSettings.Format.IniFormat)
monkeypatch.setattr(main_window, 'QSettings', lambda *_: settings)
@@ -33,6 +33,11 @@ def test_editor_conflict_protects_both_versions(qt_application, tmp_path, monkey
window.open_document(path); window.edit_current_markdown()
editor = window.tabs.currentWidget(); editor.replace_source_undoable('local')
if decision == 'deleted': path.unlink()
elif decision == 'same_metadata':
import os
stamp = path.stat()
path.write_text('disk')
os.utime(path, ns=(stamp.st_atime_ns, stamp.st_mtime_ns))
else: path.write_text('external modification')
def choose(*args, **kwargs):
if decision == 'cancel': return None
@@ -40,7 +45,7 @@ def test_editor_conflict_protects_both_versions(qt_application, tmp_path, monkey
return 'merged result'
monkeypatch.setattr(save_conflict, 'resolve_save_conflict', choose)
saved = window._save_editor_tab(editor, path, editor.source_text(), editor.session.signature)
assert saved == (decision in {'merge', 'deleted'})
assert saved == (decision in {'merge', 'deleted', 'same_metadata'})
if saved:
assert path.read_text() == editor.source_text() == editor.session.saved_source == 'merged result'
assert not editor.has_unsaved_changes()