98 lines
2.8 KiB
Python
98 lines
2.8 KiB
Python
"""Snapshot tests for the x402 public API surface.
|
|
|
|
These tests guard against accidental breakage when refactoring
|
|
x402.py into the pry_x402/ sub-package.
|
|
"""
|
|
|
|
# SPDX-License-Identifier: MIT
|
|
# Copyright (c) 2026 Rug Munch Media LLC
|
|
#
|
|
# Part of Pry — https://git.rugmunch.io/RugMunchMedia/pryscraper
|
|
# Licensed under MIT. See LICENSE.
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
class TestX402PublicSurface:
|
|
"""The x402 module must expose the same public API as before."""
|
|
|
|
def test_required_symbols_exist(self) -> None:
|
|
import x402
|
|
|
|
required = {
|
|
"ASSET_DECIMALS",
|
|
"EIP7702_RPC",
|
|
"X402Asset",
|
|
"X402_DEFAULT_ASSET",
|
|
"X402_DEFAULT_NETWORK",
|
|
"X402_DIR",
|
|
"X402_FACILITATOR_URL",
|
|
"X402Network",
|
|
"X402_OFFLINE_MODE",
|
|
"X402_PRICING",
|
|
"X402Scheme",
|
|
"X402_TIMEOUT_SECONDS",
|
|
"X402_WALLET",
|
|
"FacilitatorConfig",
|
|
"FacilitatorRouter",
|
|
"X402Handler",
|
|
"build_payment_required",
|
|
"create_batch_payment",
|
|
"create_payment_request",
|
|
"get_facilitator_router",
|
|
"is_batch_paid",
|
|
"require_payment_legacy",
|
|
"set_facilitator_router",
|
|
"verify_batch_payment",
|
|
}
|
|
missing = required - set(dir(x402))
|
|
assert not missing, f"Missing x402 public symbols: {missing}"
|
|
|
|
def test_pry_x402_re_exports_constants(self) -> None:
|
|
import pry_x402
|
|
|
|
required = {
|
|
"ASSET_DECIMALS",
|
|
"EIP7702_RPC",
|
|
"X402Asset",
|
|
"X402_DEFAULT_ASSET",
|
|
"X402_DEFAULT_NETWORK",
|
|
"X402_DIR",
|
|
"X402_FACILITATOR_URL",
|
|
"X402Network",
|
|
"X402_OFFLINE_MODE",
|
|
"X402_PRICING",
|
|
"X402Scheme",
|
|
"X402_TIMEOUT_SECONDS",
|
|
"X402_WALLET",
|
|
}
|
|
missing = required - set(dir(pry_x402))
|
|
assert not missing, f"Missing pry_x402 public symbols: {missing}"
|
|
|
|
def test_enum_values_unchanged(self) -> None:
|
|
from x402 import X402Asset, X402Network, X402Scheme
|
|
|
|
assert X402Scheme.EXACT == "exact"
|
|
assert X402Scheme.UPTO == "upto"
|
|
assert X402Network.BASE == "base"
|
|
assert X402Asset.USDC == "USDC"
|
|
|
|
def test_pricing_keys_unchanged(self) -> None:
|
|
import x402
|
|
|
|
expected = {
|
|
"scrape",
|
|
"crawl",
|
|
"extract",
|
|
"monitor",
|
|
"llm_call",
|
|
"template_execute",
|
|
"template_batch_execute",
|
|
"browser_automation",
|
|
"bulk_crawl",
|
|
"pdf_extract",
|
|
"ocr_extract",
|
|
"graphql_query",
|
|
"schema_extract",
|
|
}
|
|
assert set(x402.X402_PRICING.keys()) == expected
|