feat(examples): add XML contract testing example (Issue #372)#1507
Open
benaduo wants to merge 2 commits intopact-foundation:mainfrom
Open
feat(examples): add XML contract testing example (Issue #372)#1507benaduo wants to merge 2 commits intopact-foundation:mainfrom
benaduo wants to merge 2 commits intopact-foundation:mainfrom
Conversation
…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>
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #372
This PR adds a complete HTTP XML contract testing example to
examples/http/xml_example/, demonstrating how to usepact-pythonwith XML payloads.What's included:
consumer.py: AUserClientthat requests XML from a provider usingAccept: application/xmland parses responses withxml.etree.ElementTreeprovider.py: A FastAPI app with a/users/{id}endpoint returningContent-Type: application/xmlresponsestest_consumer.py: 2 Pact consumer tests (200 with XML body, 404 for unknown user)test_provider.py: 1 Pact provider verification test using uvicornconftest.py: Localpacts_pathfixturepyproject.toml: Example dependenciesexamples/http/README.mdto list the new exampleTests: All 3 pass locally.