-
Notifications
You must be signed in to change notification settings - Fork 145
feat: implement the Pact class #1418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This class is analogous to the `PactHandle` class, but is instead based on a pointer to the struct. Signed-off-by: JP-Ellis <josh@jpellis.me>
The Pact behind the PactHandle can be copied to a struct, whose pointer can subsequently be used. Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
There was a problem hiding this 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 implements the Pact class as a pointer-based wrapper for the FFI Pact model struct, enabling iteration over all interaction types through a unified interface. The changes refactor interaction iteration to use a common PactInteraction type that can be cast to specific subtypes, and add functionality to convert between PactHandle (integer reference) and Pact (pointer) representations.
Key changes:
- Refactored interaction iteration to use
PactInteractionas the base type for all interaction kinds - Implemented the
Pactclass with proper memory management for pointer-based Pact models - Added casting methods to convert generic
PactInteractionto specific subtypes (HTTP, async message, sync message)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/pact/pact.py |
Updated interactions() method to use PactInteraction for "All" kind and reordered conditional logic |
pact-python-ffi/tests/test_init.py |
Reorganized and expanded test coverage for iterators, interaction casting, and Pact model handling |
pact-python-ffi/tests/.ruff.toml |
Added ruff linting configuration for test files |
pact-python-ffi/src/pact_ffi/__init__.py |
Implemented Pact class, added interaction casting methods, implemented FFI wrapper functions, and fixed memory management logic |
💡 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 #1418 +/- ##
====================================
Coverage 54% 55%
====================================
Files 32 32
Lines 3849 3894 +45
====================================
+ Hits 2096 2144 +48
+ Misses 1753 1750 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
5242f1a to
9ca3eed
Compare
The PactInteraction is generic and can be cast down to the relevant subtype as need be. Signed-off-by: JP-Ellis <josh@jpellis.me>
Signed-off-by: JP-Ellis <josh@jpellis.me>
This simplifies/reorganises tests to make them more logically organised, and more intentful (even if not as exhaustive). Signed-off-by: JP-Ellis <josh@jpellis.me>
9ca3eed to
c20e33e
Compare
📝 Summary
Main changes are:
chore: refactor ffi tests
This simplifies/reorganises tests to make them more logically organised, and
more intentful (even if not as exhaustive).
feat: use common PactInteraction type
The PactInteraction is generic and can be cast down to the relevant subtype as
need be.
chore: ensure pact interactions get deleted
fix: incorrect sync http deletion
feat: add iterator over all interactions
feat: add casting interaction to subtypes
feat: add handle to pointer conversion
The Pact behind the PactHandle can be copied to a struct, whose pointer can subsequently be used.
feat: implement the Pact class
This class is analogous to the
PactHandleclass, but is instead based on a pointer to the struct.🚨 Breaking Changes
The output type of
interactions("All")has been changed toPactInteraction; however, the previous change was not released and therefore this is not a breaking change unless you have been using bleeding edge builds from themainbreanch.🔥 Motivation
Add the ability to iterate over all interactions.
🔨 Test Plan
Unit tests have been updated accordingly.
🔗 Related issues/PRs
Allinteractions iterator #451