Skip to content

web_fetch — all cases

Every case file under src/clauz3/stdlib/web_fetch/tests/cases/, inlined. _pass cases must prove; _fail cases must not.

See the curated walk-through for the trusted module and contract vocabulary.

src/clauz3/stdlib/web_fetch/tests/cases/fetches_at_most_fail.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.fetches_at_most(1))
def main() -> None:
    fetch_url("https://example.com/a")
    fetch_url("https://example.com/b")

src/clauz3/stdlib/web_fetch/tests/cases/fetches_at_most_pass.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.fetches_at_most(2))
def main() -> None:
    fetch_url("https://example.com/a")
    fetch_url("https://example.com/b")

src/clauz3/stdlib/web_fetch/tests/cases/https_only_fail.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.https_only())
def main() -> None:
    fetch_url("http://example.com/")

src/clauz3/stdlib/web_fetch/tests/cases/https_only_pass.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.https_only())
def main() -> None:
    fetch_url("https://example.com/")

src/clauz3/stdlib/web_fetch/tests/cases/never_fetch_under_fail.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.never_fetch_under("https://internal.corp/"))
def main() -> None:
    fetch_url("https://internal.corp/private/data")

src/clauz3/stdlib/web_fetch/tests/cases/never_fetch_under_pass.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.never_fetch_under("https://internal.corp/"))
def main() -> None:
    fetch_url("https://api.github.com/repos/x/y")

src/clauz3/stdlib/web_fetch/tests/cases/no_fetches_fail.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.no_fetches())
def main() -> None:
    fetch_url("https://example.com/")

src/clauz3/stdlib/web_fetch/tests/cases/no_fetches_pass.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web

import clauz3


@clauz3.guarantee(web.no_fetches())
def main() -> None:
    pass

src/clauz3/stdlib/web_fetch/tests/cases/no_url_contains_fail.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.no_url_contains("token="))
def main() -> None:
    fetch_url("https://api.example.com/?token=ghp_secret")

src/clauz3/stdlib/web_fetch/tests/cases/no_url_contains_pass.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.no_url_contains("token="))
def main() -> None:
    fetch_url("https://api.github.com/repos/x/y")

src/clauz3/stdlib/web_fetch/tests/cases/only_fetch_under_fail.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.only_fetch_under("https://api.github.com/"))
def main() -> None:
    fetch_url("https://evil.example.com/exfil")

src/clauz3/stdlib/web_fetch/tests/cases/only_fetch_under_pass.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.only_fetch_under("https://api.github.com/repos/"))
def main() -> None:
    fetch_url("https://api.github.com/repos/normalform-ai/clauz3")

src/clauz3/stdlib/web_fetch/tests/cases/url_length_at_most_fail.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.url_length_at_most(30))
def main() -> None:
    fetch_url("https://example.com/very/long/path/with/many/segments?q=stuff")

src/clauz3/stdlib/web_fetch/tests/cases/url_length_at_most_pass.py

# ruff: noqa: F821
from tools.web_fetch.trusted import contracts as web
from tools.web_fetch.trusted.effects import fetch_url

import clauz3


@clauz3.guarantee(web.url_length_at_most(60))
def main() -> None:
    fetch_url("https://example.com/short")