mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-14 22:52:15 +02:00
test(capabilities): cover REST door, meter-gate, and batch bounds
This commit is contained in:
parent
b1e49f21f2
commit
b1bd35c082
5 changed files with 291 additions and 4 deletions
|
|
@ -1,10 +1,16 @@
|
|||
"""ScrapeOutput reports its own billable count (a success single-sources it)."""
|
||||
"""ScrapeOutput reports its own billable count; ScrapeInput bounds its batch size."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from app.capabilities.web.scrape.schemas import ScrapeOutput, ScrapeRow
|
||||
from app.capabilities.web.scrape.schemas import (
|
||||
MAX_SCRAPE_URLS,
|
||||
ScrapeInput,
|
||||
ScrapeOutput,
|
||||
ScrapeRow,
|
||||
)
|
||||
|
||||
pytestmark = pytest.mark.unit
|
||||
|
||||
|
|
@ -24,3 +30,18 @@ def test_billable_units_counts_successful_rows():
|
|||
|
||||
def test_billable_units_is_zero_without_successes():
|
||||
assert _output("empty", "failed").billable_units == 0
|
||||
|
||||
|
||||
def test_rejects_empty_url_batch():
|
||||
with pytest.raises(ValidationError):
|
||||
ScrapeInput(urls=[])
|
||||
|
||||
|
||||
def test_rejects_batch_over_the_cap():
|
||||
with pytest.raises(ValidationError):
|
||||
ScrapeInput(urls=[f"https://{i}.com" for i in range(MAX_SCRAPE_URLS + 1)])
|
||||
|
||||
|
||||
def test_accepts_batch_at_the_cap():
|
||||
payload = ScrapeInput(urls=[f"https://{i}.com" for i in range(MAX_SCRAPE_URLS)])
|
||||
assert payload.estimated_units == MAX_SCRAPE_URLS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue