feat: add support for iterating all interaction types via Pact.interactions("All") FFI and relevant tests#1401
Conversation
…ctions("All") FFI and tests
There was a problem hiding this comment.
Pull request overview
This PR adds support for iterating over all interaction types in a Pact using Pact.interactions("All"). The implementation introduces a new FFI wrapper for the PactMessageIterator from the upstream Rust library, exposes it through the Python API with proper type hints, and provides comprehensive test coverage for the new functionality.
Key changes:
- Added
PactMessageIteratorFFI wrapper class with full iterator protocol support - Implemented
PactInteractionclass to represent generic interactions returned by the "All" iterator - Extended
Pact.interactions()method to accept "All" as a kind parameter - Added test coverage for the new "All" interaction type in both empty and mixed interaction scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tests/test_pact.py |
Added "All" to parametrized test for empty pacts; added comprehensive test for mixed interaction types |
src/pact/pact.py |
Added "All" literal type and overload signature; implemented "All" case in interactions() method; removed TODO comment |
pact-python-ffi/src/pact_ffi/__init__.py |
Implemented PactInteraction class; added PactMessageIterator class with iterator protocol; added pact_message_iter_next/delete and pact_handle_get_message_iter FFI functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1401 +/- ##
====================================
+ Coverage 52% 54% +1%
====================================
Files 32 32
Lines 3805 3849 +44
====================================
+ Hits 2000 2096 +96
+ Misses 1805 1753 -52
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
69255f1 to
c4ffc78
Compare
c4ffc78 to
ed4f051
Compare
|
The failing tests are due to Gateway time out error (504) and unrelated to the changes. |
|
Wow thanks for the PR! I'll need to spend a bit of time reviewing this first, but it's looking pretty good from the glance I took! |
Just to help organise the tests more logically. Signed-off-by: JP-Ellis <[email protected]>
a1f2e5f to
c01ac57
Compare
|
Awesome work! I have done a minor refactor to start grouping some tests into test classes; especially for the |
Pre-flight checklist
Allinteractions iterator #451) and the maintainers have approved on my working plan.Summary
This PR adds support for iterating over all interaction types using
Pact.interactions("All"). It introduces a new FFI iterator, updates the core API, and provides comprehensive tests to verify the new behavior. The implementation follows existing code patterns for iterators and FFI bindings.Breaking Changes
None.
Motivation
This change closes #451 by enabling users to access all interaction types in a Pact object, improving API flexibility and usability. The update aligns with upstream capabilities and ensures consistency with other iterator patterns in the codebase.
Test Plan
tests/test_pact.pyto cover the new "All" interactions feature.pytest.Related issues/PRs
Allinteractions iterator #451