69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
from __future__ import annotations
|
|
|
|
from app.core.agent.processes.v2.workflows.doc_explain_api_exposed.steps.retrieval.api_endpoint_collector import (
|
|
ApiEndpointCollector,
|
|
)
|
|
|
|
|
|
def test_collector_returns_method_and_path_lines() -> None:
|
|
rows = [
|
|
{
|
|
"metadata": {
|
|
"endpoint": "GET|POST /actions/{action}",
|
|
"summary_text": "Endpoint for runtime control actions",
|
|
},
|
|
"title": "HTTP API /actions/{action}",
|
|
"path": "docs/api/control-actions-endpoint.md",
|
|
"content": "",
|
|
},
|
|
{
|
|
"metadata": {
|
|
"endpoint": "GET /health",
|
|
},
|
|
"title": "HTTP API /health",
|
|
"path": "docs/api/health-endpoint.md",
|
|
"content": "",
|
|
},
|
|
]
|
|
|
|
endpoints = ApiEndpointCollector().collect(rows)
|
|
|
|
assert "GET /actions/{action}" in endpoints
|
|
assert "POST /actions/{action}" in endpoints
|
|
assert "GET /health" in endpoints
|
|
|
|
|
|
def test_collector_ignores_file_paths_from_content() -> None:
|
|
rows = [
|
|
{
|
|
"metadata": {
|
|
"endpoint": "GET /health",
|
|
"summary_text": "Uses src/telegram_notify_app/control_api.py",
|
|
},
|
|
"title": "Health endpoint",
|
|
"path": "docs/api/health-endpoint.md",
|
|
"content": "See /telegram_notify_app/control_api.py and /telegram_notify_app/worker.py",
|
|
}
|
|
]
|
|
|
|
endpoints = ApiEndpointCollector().collect(rows)
|
|
|
|
assert endpoints == ["GET /health"]
|
|
|
|
|
|
def test_collector_ignores_title_when_endpoint_metadata_missing() -> None:
|
|
rows = [
|
|
{
|
|
"metadata": {
|
|
"summary_text": "Control actions endpoint",
|
|
},
|
|
"title": "HTTP API /actions/{action}",
|
|
"path": "docs/api/control-actions-endpoint.md",
|
|
"content": "",
|
|
}
|
|
]
|
|
|
|
endpoints = ApiEndpointCollector().collect(rows)
|
|
|
|
assert endpoints == []
|