Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 42 additions & 36 deletions .cspell/custom-words.txt
Original file line number Diff line number Diff line change
@@ -1,81 +1,87 @@
# cspell-specific custom words related to UCP
absl
absltest
adyen
Adyen
agentic
Alam
Amex
Ant
Anytown
atok
backorder
Backordered
Braintree
Carrefour
Centricity
checkout
Chewy
Commerce
Credentialless
Depot
EWALLET
Etsy
Flipkart
Gap
GitHub
Google
Gpay
Kroger
Lowe's
Macy's
Mastercard
Paymentech
Paypal
Preorders
Queensway
Sephora
Shopify
Shopee
Stripe
Target
UCP
Ulta
Visa
Wayfair
Worldpay
Zalando
absl
absltest
adyen
agentic
atok
backorder
checkout
credentialless
credentialization
credentialless
Credentialless≈
cust
datamodel
Depot
dpan
Etsy
ewallet
EWALLET
Flipkart
fontawesome
fpan
fulfillable
Gap
GitHub
Google
gpay
Gpay
healthz
ingestions
inlinehilite
Kroger
linenums
llmstxt
Lowe's
Macy's
Malform
mastercard
Mastercard
mkdocs
mtok
openapi
openrpc
Paymentech
paypal
Paypal
permissionless
preorders
Preorders
proto
protobuf
pymdownx
Queensway
renderable
repudiable
schemas
sdjwt
Sephora
Shopee
shopify
Shopify
Smallville
Stripe
superfences
Target
UCP
Ulta
Villagetown
Visa
vulnz
Wayfair
Worldpay
wumpus
Wumpus
yaml
yml
Zalando
12 changes: 5 additions & 7 deletions idempotency_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ def test_idempotency_update(self) -> None:
# We construct the update payload same as helper does
line_items_req = []
for li in checkout_obj.line_items:
line_items_req.append(
{
"item": {"id": li.item.id, "title": li.item.title},
"quantity": 2, # Change quantity
"id": li.id,
}
)
line_items_req.append({
"item": {"id": li.item.id, "title": li.item.title},
"quantity": 2, # Change quantity
"id": li.id,
})

payment_req = {
"selected_instrument_id": checkout_obj.payment.selected_instrument_id,
Expand Down
49 changes: 49 additions & 0 deletions integration_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,55 @@ def assert_response_status(
),
)

def assert_checkout_status(
self,
checkout_data: dict[str, Any],
expected_status: str = "incomplete",
valid_path_matchers: list[str] | None = None,
model_class: Any = None,
) -> Any:
"""Assert checkout status and optionally verify error paths using Pydantic."""
if model_class is None:
# Use a more permissive model that only requires status and messages for errors
from pydantic import BaseModel
from ucp_sdk.models.schemas.shopping.types import message

class BasicErrorResponse(BaseModel):
status: str
messages: list[message.Message] | None = None

model_class = BasicErrorResponse

checkout_obj = model_class(**checkout_data)

self.assertEqual(
checkout_obj.status,
expected_status,
msg=f"Expected checkout status '{expected_status}', got '{checkout_obj.status}'.",
)

if valid_path_matchers:
# Extract error messages from the Pydantic model
error_messages = [
msg.root
for msg in (checkout_obj.messages or [])
if getattr(msg.root, "type", None) == "error"
]

error_paths = [getattr(m, "path", "") for m in error_messages]

matches = any(
any(path == matcher for matcher in valid_path_matchers)
for path in error_paths
)

self.assertTrue(
matches,
f"Expected error path matching one of {valid_path_matchers}. Paths found: {error_paths}",
)

return checkout_obj

def create_checkout_session(
self,
quantity: int = 1,
Expand Down
7 changes: 4 additions & 3 deletions protocol_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ def _extract_document_urls(
if service.mcp and service.mcp.schema_:
urls.add((f"{base_path}.mcp.schema", str(service.mcp.schema_)))
if service.embedded and service.embedded.schema_:
urls.add(
(f"{base_path}.embedded.schema", str(service.embedded.schema_))
)
urls.add((
f"{base_path}.embedded.schema",
str(service.embedded.schema_),
))

# 2. Capabilities
for i, cap in enumerate(profile.ucp.capabilities):
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ docstring-code-format = true
[tool.ruff.lint]
select = ["E", "F", "W", "B", "C4", "SIM", "N", "UP", "D", "PTH", "T20"]
ignore = ["D203", "D213"]
# Don't fail on lines ruff format can't fix
ignore = ["E501"]

[tool.ruff.lint.isort]
combine-as-imports = true
Expand Down
Loading
Loading