Link-integrity crawl helpers for shell apps (#234).
app.check() and TestClientstring asserts validate contracts but cannot
prove that everyhrefthe shell renders resolves. These helpers render seed
pages, collect same-origin paths from the HTML, and GET each one — the cheap
deterministic counterpart to a full browser smoke.
testing.link_crawl
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
Return crawlable same-origin paths embedded inhtml.
Strips#fragmentanchors and query strings, drops external schemes,
relative non-root paths, static assets (whenskip_static=True…
Outcome of a link-integrity crawl.
Render seed_pages, collect hrefs, and GET every discovered path.
Returns aLinkCrawlResultwith the union of discovered paths and a
brokenmap of …
Assert every same-origin link from seed_pages resolves.
When require_links is true, an empty discovered set fails (guards against
a vacuous crawl). Returns theLinkCrawlResult…
same_origin_paths
function
def same_origin_paths(html: str, *, skip_static: bool = True, skip_suffixes: Iterable[str] = _DEFAULT_SKIP_SUFFIXES) -> set[str]
Return crawlable same-origin paths embedded inhtml.
Strips#fragmentanchors and query strings, drops external schemes,
relative non-root paths, static assets (whenskip_static=True), and
paths ending with anyskip_suffixesentry (SSE streams, etc.).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
html
|
str
|
— | |
skip_static
|
bool
|
True
|
|
skip_suffixes
|
Iterable[str]
|
_DEFAULT_SKIP_SUFFIXES
|
LinkCrawlResult
class
Outcome of a link-integrity crawl.
crawl_links
function
async
async def crawl_links(client: Any, seed_pages: Iterable[str], *, headers: Mapping[str, str] | None = None, expected_status: int = 200, skip_static: bool = True, skip_suffixes: Iterable[str] = _DEFAULT_SKIP_SUFFIXES) -> LinkCrawlResult
Render seed_pages, collect hrefs, and GET every discovered path.
Returns aLinkCrawlResultwith the union of discovered paths and a
broken map of path -> statusfor responses that did not match
expected_status. Seed pages that fail to render raiseAssertionError.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
client
|
Any
|
— | |
seed_pages
|
Iterable[str]
|
— | |
headers
|
Mapping[str, str] | None
|
None
|
|
expected_status
|
int
|
200
|
|
skip_static
|
bool
|
True
|
|
skip_suffixes
|
Iterable[str]
|
_DEFAULT_SKIP_SUFFIXES
|
assert_link_integrity
function
async
async def assert_link_integrity(client: Any, seed_pages: Iterable[str], *, headers: Mapping[str, str] | None = None, expected_status: int = 200, skip_static: bool = True, skip_suffixes: Iterable[str] = _DEFAULT_SKIP_SUFFIXES, require_links: bool = True) -> LinkCrawlResult
Assert every same-origin link from seed_pages resolves.
When require_links is true, an empty discovered set fails (guards against
a vacuous crawl). Returns theLinkCrawlResulton success.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
client
|
Any
|
— | |
seed_pages
|
Iterable[str]
|
— | |
headers
|
Mapping[str, str] | None
|
None
|
|
expected_status
|
int
|
200
|
|
skip_static
|
bool
|
True
|
|
skip_suffixes
|
Iterable[str]
|
_DEFAULT_SKIP_SUFFIXES
|
|
require_links
|
bool
|
True
|
View source · /home/runner/work/chirp/chirp/site/../src/chirp/testing/link_crawl.py:1