Skip to content

feat: add support for iterating all interaction types via Pact.interactions("All") FFI and relevant tests#1401

Merged
JP-Ellis merged 4 commits intopact-foundation:mainfrom
Nikhil172913832:fixing_issue_451
Dec 17, 2025
Merged

feat: add support for iterating all interaction types via Pact.interactions("All") FFI and relevant tests#1401
JP-Ellis merged 4 commits intopact-foundation:mainfrom
Nikhil172913832:fixing_issue_451

Conversation

@Nikhil172913832
Copy link
Contributor

Pre-flight checklist

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

  • Added and updated unit tests in tests/test_pact.py to cover the new "All" interactions feature.
  • Verified all tests pass locally using pytest.

Related issues/PRs

Copilot AI review requested due to automatic review settings December 11, 2025 17:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PactMessageIterator FFI wrapper class with full iterator protocol support
  • Implemented PactInteraction class 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
Copy link

codecov bot commented Dec 11, 2025

Codecov Report

❌ Patch coverage is 77.77778% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 54%. Comparing base (b889925) to head (c01ac57).
⚠️ Report is 9 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
pact-python-ffi/src/pact_ffi/__init__.py 84% 6 Missing ⚠️
src/pact/pact.py 33% 4 Missing ⚠️
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     
Flag Coverage Δ
tests 54% <77%> (+1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Nikhil172913832
Copy link
Contributor Author

The failing tests are due to Gateway time out error (504) and unrelated to the changes.

@JP-Ellis
Copy link
Contributor

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]>
@JP-Ellis
Copy link
Contributor

Awesome work! I have done a minor refactor to start grouping some tests into test classes; especially for the pact_ffi package (as that will grow to be a huge test file eventually).

@JP-Ellis JP-Ellis merged commit 02562fe into pact-foundation:main Dec 17, 2025
56 checks passed
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 All interactions iterator

3 participants