33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
"""Tests for scheduler helper functions."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from cheddahbot.scheduler import _extract_docx_paths
|
|
|
|
|
|
class TestExtractDocxPaths:
|
|
def test_extracts_paths_from_realistic_output(self):
|
|
result = (
|
|
"Press releases generated successfully!\n\n"
|
|
"**Docx:** `output/press_releases/acme-corp-launch.docx`\n"
|
|
"**Docx:** `output/press_releases/acme-corp-expansion.docx`\n"
|
|
"Files saved to output/press_releases/"
|
|
)
|
|
paths = _extract_docx_paths(result)
|
|
|
|
assert len(paths) == 2
|
|
assert paths[0] == "output/press_releases/acme-corp-launch.docx"
|
|
assert paths[1] == "output/press_releases/acme-corp-expansion.docx"
|
|
|
|
def test_returns_empty_list_when_no_paths(self):
|
|
result = "Task completed successfully. No files generated."
|
|
paths = _extract_docx_paths(result)
|
|
|
|
assert paths == []
|
|
|
|
def test_only_matches_docx_extension(self):
|
|
result = "**Docx:** `report.docx`\n**PDF:** `report.pdf`\n**Docx:** `summary.txt`\n"
|
|
paths = _extract_docx_paths(result)
|
|
|
|
assert paths == ["report.docx"]
|