Files
stack/tests/prisma/test_harvest.py

28 lines
753 B
Python

"""Grey-literature HTML parsers. No HTTP."""
from __future__ import annotations
import pytest
from prisma.harvest import PARSERS, Harvested
_SOURCES = ("cms", "medpac", "macpac", "aspe", "gao", "cbo", "crs", "kff")
_HTML = '<a href="https://example.test/r">Report title</a><time>2026-01-02</time>'
@pytest.mark.parametrize("source", _SOURCES)
def test_parser_reads_the_report_link_and_date(source: str):
assert PARSERS[source](_HTML) == (
Harvested(
title="Report title",
url="https://example.test/r",
date="2026-01-02",
source=source,
),
)
@pytest.mark.parametrize("source", _SOURCES)
def test_empty_html_returns_nothing(source: str):
assert PARSERS[source]("") == ()