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
+21 -1
View File
@@ -4,7 +4,7 @@ import zipfile
from pathlib import Path
import pytest
from PIL import Image
from PySide6.QtCore import QSettings
from PySide6.QtCore import QSettings, Qt
from mdhelper.batch_documents import BatchDocument, combine_documents, fingerprint, publish_outputs
from mdhelper.batch_export_dialog import BatchExportDialog
from mdhelper.docx_exporter import export_markdown_to_docx
@@ -61,6 +61,26 @@ def test_publication_cancellation_race_and_rollback(tmp_path, monkeypatch):
assert all(path.read_bytes() == b'old' for path in destinations)
def test_combined_export_confirms_final_filename_after_extension_change(qt_application, tmp_path, monkeypatch):
from mdhelper import batch_export_dialog as ui
docs = documents(tmp_path)
settings = QSettings(str(tmp_path / 'settings.ini'), QSettings.Format.IniFormat)
monkeypatch.setattr(main_window, 'QSettings', lambda *_: settings)
window = main_window.MainWindow(tmp_path)
panel = BatchExportDialog(window)
output = tmp_path / 'chosen.docx'; output.write_bytes(b'existing export')
questions = []
monkeypatch.setattr(window.exports, '_choose_page_settings', lambda: PageSettings())
monkeypatch.setattr(ui.QFileDialog, 'getSaveFileName', lambda *args, **kwargs: (str(tmp_path / 'chosen.txt'), ''))
monkeypatch.setattr(ui.QMessageBox, 'question', lambda *args: questions.append(args[2]) or ui.QMessageBox.StandardButton.No)
try:
panel.files.item(0).setCheckState(Qt.CheckState.Checked)
panel.combined.setChecked(True)
panel.start()
assert str(output) in questions[0] and not panel.running and output.read_bytes() == b'existing export'
finally: panel.close(); window.close()
@pytest.mark.parametrize('kind,combined', [('docx', False), ('pdf', True), ('pdf', False)])
def test_queue_generates_complete_outputs(qt_application, tmp_path, monkeypatch, kind, combined):
docs = documents(tmp_path)