Files
mentor-pdf-exporter/tests/test_profiles.py
T

34 lines
1.5 KiB
Python

from pathlib import Path
from mentor_pdf_export.models import ExportOptions
from mentor_pdf_export.profiles import write_profile, build_command
def test_profile_clears_url_and_preserves_fonts(tmp_path):
ini = tmp_path / "dxpdf.ini"
ini.write_text("Color 1\nUrlProperties Value\nStartAcrobat 1\nFont_1 Courier-Bold\n")
write_profile(ini, ExportOptions())
lines = ini.read_text().splitlines()
assert "Color 4" in lines
assert "UrlProperties " in lines
assert "StartAcrobat 0" in lines
assert "Font_1 Courier-Bold" in lines
assert "ChangeIct2Sch 1" in lines
assert "VisibleHLs 0" in lines
def test_command_is_argument_list_not_shell():
args = build_command(Path("engine.exe"), Path("工程 x.prj"), Path("x.pdf"), ExportOptions(schematic="ROOT"))
assert args[:3] == ["engine.exe", "-project", "工程 x.prj"]
assert args[args.index("-c") + 1] == "4"
assert args[args.index("-schematic") + 1] == "ROOT"
assert "-p" in args and "-e" in args and "-i2s" in args
assert "-s" not in args and "-v" not in args and "-i" not in args
def test_disabled_flags_not_enabled():
args = build_command(Path("engine.exe"), Path("a.prj"), Path("a.pdf"), ExportOptions(popup=False, use_exclusion=False, change_ict=False))
assert "-p" not in args and "-e" not in args and "-i2s" not in args
def test_stroke_mode_uses_native_verified_attached_switch():
args=build_command(Path("engine.exe"),Path("a.prj"),Path("a.pdf"),ExportOptions(stroke_fonts=True))
assert "-uAll" in args
assert "-u" not in args and "-udx" not in args