"""Journal Formatter and Journal Finder tabs (no network: the journal lookup and the search itself are not run).""" import json import os import sys import zipfile from pathlib import Path import pytest import finder_tab as FND import formatter_tab as FMT ROOT = Path(__file__).resolve().parent.parent progress = lambda *a, **k: None def _manuscript(tmp_path): from docx import Document d = Document() d.add_heading("A Hybrid Deep Learning Framework for Intrusion Detection", 0) d.add_paragraph("Ravi Kumar, Priya Sharma") d.add_paragraph("Abstract: This study proposes a hybrid model that reaches 98.4% accuracy on a public dataset.") d.add_heading("Introduction", 1) d.add_paragraph("Medical devices are increasingly connected (Smith, 2020). Prior work used shallow models.") d.add_heading("References", 1) d.add_paragraph("Smith, J. (2020). Deep learning for intrusion detection. Journal of Network Security, 12(3), " "45-67.") p = tmp_path / "my paper.docx" d.save(str(p)) return str(p) # ---------------------------------------------------------------- formatter def test_formatter_engine_is_available(): assert FMT.AVAILABLE, FMT.WHY assert len(FMT._preset_choices()) > 10 and FMT._preset_key(FMT.AUTO) is None def test_format_gives_word_latex_report_and_an_overleaf_button(tmp_path): style = FMT.PRESETS["ieee_journal"]["name"] status, dl, docx, zip_, md, overleaf, report = FMT.format_doc(_manuscript(tmp_path), "", style, None, "", "", True, True, False, FMT.REF_STYLES[0], FMT.CITE_MODES[0], progress) assert "Formatted as" in status and "checks passed" in status assert docx.endswith("my_paper_formatted.docx") and Path(docx).stat().st_size > 5000 names = zipfile.ZipFile(zip_).namelist() assert "main.tex" in names and not any(n.startswith("/") for n in names) # main.tex at the top level main = zipfile.ZipFile(zip_).read("main.tex").decode("utf-8") assert "\\documentclass" in main and "IEEEtran" in main and "\\begin{document}" in main assert Path(md).read_text(encoding="utf-8").startswith("# Formatting report") and "Compliance" in report # Overleaf: instructions only; the customer downloads the zip and uploads it himself assert "Upload Project" in overleaf and "