diff --git a/.gitignore b/.gitignore index 77ac754..0e7a2f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,30 @@ -.venv/ +# Python __pycache__/ *.pyc +*.pyo +.pytest_cache/ +*.egg-info/ +.venv/ +venv/ + +# macOS +.DS_Store + +# Logs +*.log +firebase-debug.log + +# Backups +*.bak +sailo-claude-backup/ + +# AW local state (PostgreSQL is source of truth) +.aw/ + +# Local databases +vectors.db +*.db + +# Generated test artifacts +tests/_tmp_*.docx +tests/_tmp_*.pdf diff --git a/tests/test_md2doc_integration.py b/tests/test_md2doc_integration.py new file mode 100644 index 0000000..d044256 --- /dev/null +++ b/tests/test_md2doc_integration.py @@ -0,0 +1,60 @@ +"""Integration test — full md → docx conversion on pluxee-todo.md fixture.""" +import subprocess +import sys +import zipfile +import xml.etree.ElementTree as ET +from pathlib import Path + +REPO = Path(__file__).parent.parent +FIXTURE = REPO / "pluxee-todo.md" +W_NS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main" + + +def test_convert_pluxee_todo_creates_valid_docx(tmp_path): + out = tmp_path / "pluxee.docx" + r = subprocess.run( + [sys.executable, "md2doc.py", str(FIXTURE), "-o", str(out)], + cwd=REPO, capture_output=True, text=True + ) + assert r.returncode == 0, f"Conversion failed: {r.stderr}" + assert out.exists() + assert out.stat().st_size > 0 + + +def test_converted_docx_has_headings_and_paragraphs(tmp_path): + out = tmp_path / "pluxee.docx" + subprocess.run( + [sys.executable, "md2doc.py", str(FIXTURE), "-o", str(out), "-q"], + cwd=REPO, capture_output=True, text=True + ) + with zipfile.ZipFile(out) as z: + root = ET.fromstring(z.read("word/document.xml")) + headings = list(root.iter(f"{{{W_NS}}}pStyle")) + heading_vals = [h.get(f"{{{W_NS}}}val") for h in headings] + assert any(v and v.startswith("Heading") for v in heading_vals), \ + f"expected at least one Heading style, got {heading_vals}" + + +def test_image_in_markdown_warns_to_stderr(tmp_path): + md_with_image = tmp_path / "img.md" + md_with_image.write_text("# Test\n\n![alt text](https://example.com/x.png)\n") + out = tmp_path / "img.docx" + r = subprocess.run( + [sys.executable, "md2doc.py", str(md_with_image), "-o", str(out)], + cwd=REPO, capture_output=True, text=True + ) + assert r.returncode == 0 # warning, not error + assert "image" in r.stderr.lower() or "skip" in r.stderr.lower() + + +def test_directory_mode_converts_all_md(tmp_path): + (tmp_path / "a.md").write_text("# A\n") + (tmp_path / "b.md").write_text("# B\n") + out_dir = tmp_path / "out" + r = subprocess.run( + [sys.executable, "md2doc.py", str(tmp_path), "-o", str(out_dir)], + cwd=REPO, capture_output=True, text=True + ) + assert r.returncode == 0 + assert (out_dir / "a.docx").exists() + assert (out_dir / "b.docx").exists()