v0.6.0 BigUpdate
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
"""Output path when the GUI switches between MD → DOCX and DOCX → MD."""
|
||||
|
||||
import os
|
||||
|
||||
from md2gost.gui import (
|
||||
coerce_docx_output,
|
||||
import_output_path,
|
||||
next_import_output,
|
||||
next_markdown_output,
|
||||
output_tracks_source,
|
||||
)
|
||||
from md2gost.pipeline import default_output_path
|
||||
|
||||
|
||||
def test_import_markdown_counts_as_automatic(tmp_path):
|
||||
docx = tmp_path / "шаблон таблицы.docx"
|
||||
imported = import_output_path(str(docx))
|
||||
assert imported.endswith(".md")
|
||||
assert output_tracks_source(str(docx), imported)
|
||||
# default_output_path appends .docx and must not be the import target
|
||||
assert not output_tracks_source(str(docx), default_output_path(str(docx)))
|
||||
|
||||
|
||||
def test_markdown_after_import_uses_docx(tmp_path):
|
||||
"""MD → DOCX, then DOCX → MD, then another .md must not keep the .md output."""
|
||||
report = tmp_path / "1исп.md"
|
||||
imported = import_output_path(str(tmp_path / "шаблон таблицы.docx"))
|
||||
|
||||
out, auto = next_markdown_output(str(report), imported, auto=True)
|
||||
assert out == default_output_path(str(report))
|
||||
assert auto is True
|
||||
|
||||
# Old GUI cleared the auto flag after import, so the .md path stuck.
|
||||
out, auto = next_markdown_output(str(report), imported, auto=False)
|
||||
assert out == default_output_path(str(report))
|
||||
assert out.lower().endswith(".docx")
|
||||
assert auto is True
|
||||
|
||||
|
||||
def test_custom_docx_is_kept_when_switching_markdown(tmp_path):
|
||||
other = tmp_path / "other.md"
|
||||
custom = str(tmp_path / "pinned.docx")
|
||||
out, auto = next_markdown_output(str(other), custom, auto=False)
|
||||
assert out == custom
|
||||
assert auto is False
|
||||
|
||||
|
||||
def test_import_replaces_previous_docx_target(tmp_path):
|
||||
src = tmp_path / "шаблон таблицы.docx"
|
||||
previous = str(tmp_path / "report.docx")
|
||||
out, auto = next_import_output(str(src), previous, auto=False)
|
||||
assert os.path.normcase(out) == os.path.normcase(import_output_path(str(src)))
|
||||
assert auto is True
|
||||
|
||||
|
||||
def test_convert_does_not_reuse_import_markdown(tmp_path):
|
||||
report = tmp_path / "1исп.md"
|
||||
stale = str(tmp_path / "шаблон таблицы.md")
|
||||
assert coerce_docx_output(str(report), stale) == default_output_path(str(report))
|
||||
keep = str(tmp_path / "keep.docx")
|
||||
assert coerce_docx_output(str(report), keep) == keep
|
||||
Reference in New Issue
Block a user