Skip to content

feat(examples): add XML contract testing example (Issue #372)#1507

Open
benaduo wants to merge 2 commits intopact-foundation:mainfrom
benaduo:main
Open

feat(examples): add XML contract testing example (Issue #372)#1507
benaduo wants to merge 2 commits intopact-foundation:mainfrom
benaduo:main

Conversation

@benaduo
Copy link

@benaduo benaduo commented Mar 19, 2026

Closes #372

This PR adds a complete HTTP XML contract testing example to examples/http/xml_example/, demonstrating how to use pact-python with XML payloads.

What's included:

  • consumer.py: A UserClient that requests XML from a provider using Accept: application/xml and parses responses with xml.etree.ElementTree
  • provider.py: A FastAPI app with a /users/{id} endpoint returning Content-Type: application/xml responses
  • test_consumer.py: 2 Pact consumer tests (200 with XML body, 404 for unknown user)
  • test_provider.py: 1 Pact provider verification test using uvicorn
  • conftest.py: Local pacts_path fixture
  • pyproject.toml: Example dependencies
  • Updated examples/http/README.md to list the new example

Tests: All 3 pass locally.

benaduo and others added 2 commits March 20, 2026 00:44
…on#372)

- Add examples/http/xml_example/ with consumer, provider, and tests
- Consumer uses xml.etree.ElementTree to parse XML responses
- Provider is a FastAPI app returning application/xml responses
- Tests cover GET user (200) and unknown user (404) scenarios
- Add local conftest.py with pacts_path fixture
- Update examples/http/README.md to list new example

Co-Authored-By: Abacus.AI CLI <agent@abacus.ai>
@benaduo
Copy link
Author

benaduo commented Mar 19, 2026

Hi @JP-Ellis, I've opened this PR to address issue #372, adding a complete XML contract testing example using xml.etree.ElementTree with FastAPI as the provider. All 3 tests pass locally. Would appreciate a review when you get the chance. Happy to make any changes you need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a complete XML example

1 participant