moved html mocks to html sub folder and updated conftest.py to read from new location with better path and endpoint handling
This commit is contained in:
@@ -8,7 +8,7 @@ from omniread.core.content import ContentType
|
||||
from omniread.html.scraper import HTMLScraper
|
||||
|
||||
|
||||
MOCK_DIR = Path(__file__).parent / "mocks"
|
||||
MOCK_HTML_DIR = Path(__file__).parent / "mocks" / "html"
|
||||
|
||||
|
||||
def render_html(template_path, data_path) -> bytes:
|
||||
@@ -30,23 +30,17 @@ def mock_transport(request: httpx.Request) -> httpx.Response:
|
||||
httpx MockTransport handler.
|
||||
"""
|
||||
path = request.url.path
|
||||
|
||||
if path == "/simple":
|
||||
content = render_html(
|
||||
MOCK_DIR / "simple.html.jinja",
|
||||
MOCK_DIR / "simple.json",
|
||||
)
|
||||
elif path == "/table":
|
||||
content = render_html(
|
||||
MOCK_DIR / "table.html.jinja",
|
||||
MOCK_DIR / "table.json",
|
||||
)
|
||||
else:
|
||||
if path not in ['/simple', '/table']:
|
||||
return httpx.Response(
|
||||
status_code=404,
|
||||
content=b"Not Found",
|
||||
request=request,
|
||||
)
|
||||
endpoint = path.split("/")[-1]
|
||||
content = render_html(
|
||||
MOCK_HTML_DIR / f"{endpoint}.html.jinja",
|
||||
MOCK_HTML_DIR / f"{endpoint}.json",
|
||||
)
|
||||
|
||||
return httpx.Response(
|
||||
status_code=200,
|
||||
|
||||
Reference in New Issue
Block a user