81 lines
2.2 KiB
Python
81 lines
2.2 KiB
Python
"""Shared test fixtures."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from link_building_workflow import BLMConfig, Deps, LLMCheck
|
|
|
|
|
|
@pytest.fixture()
|
|
def blm_dir(tmp_path: Path) -> Path:
|
|
"""A fake BLM directory on disk so run_blm_command's existence check passes."""
|
|
d = tmp_path / "blm"
|
|
d.mkdir()
|
|
# Touch main.py so any accidental real subprocess call gets further; we
|
|
# still mock subprocess.run in tests, but this is a harmless safety net.
|
|
(d / "main.py").write_text("# fake\n")
|
|
return d
|
|
|
|
|
|
@pytest.fixture()
|
|
def blm_config(blm_dir: Path) -> BLMConfig:
|
|
return BLMConfig(
|
|
blm_dir=str(blm_dir),
|
|
username="testuser",
|
|
password="testpass",
|
|
timeout_seconds=300,
|
|
python_exe="python",
|
|
)
|
|
|
|
|
|
@pytest.fixture()
|
|
def llm_never() -> LLMCheck:
|
|
"""LLM check that always returns False (fast-path only matches)."""
|
|
return lambda a, b: False
|
|
|
|
|
|
@pytest.fixture()
|
|
def llm_always() -> LLMCheck:
|
|
"""LLM check that always returns True (treat everything as plural-equiv)."""
|
|
return lambda a, b: True
|
|
|
|
|
|
@pytest.fixture()
|
|
def deps(blm_config: BLMConfig, llm_never) -> Deps:
|
|
return Deps(blm=blm_config, llm_check=llm_never)
|
|
|
|
|
|
# Canonical ingest stdout, matches the BLM output format the parser is tuned for
|
|
@pytest.fixture()
|
|
def ingest_success_stdout() -> str:
|
|
return (
|
|
"Authenticated as: testuser (User)\n"
|
|
"\n"
|
|
"Parsing CORA file: /tmp/test.xlsx\n"
|
|
"Main Keyword: precision cnc machining\n"
|
|
"Word Count: 1500\n"
|
|
"\n"
|
|
"Creating project: Test Project\n"
|
|
"Money Site URL: https://example.com\n"
|
|
"\n"
|
|
"Success: Project 'Test Project' created (ID: 42)\n"
|
|
"Main Keyword: precision cnc machining\n"
|
|
"Money Site URL: https://example.com\n"
|
|
"Job file created: jobs/test-project.json\n"
|
|
)
|
|
|
|
|
|
@pytest.fixture()
|
|
def generate_success_stdout() -> str:
|
|
return (
|
|
"Loading job file: jobs/test-project.json\n"
|
|
"Generating backlink 1 of 10...\n"
|
|
"Generating backlink 2 of 10...\n"
|
|
"...\n"
|
|
"All backlinks generated.\n"
|
|
"Job file moved to: jobs/done/test-project.json\n"
|
|
)
|