Skip to content

Conversation

@JP-Ellis
Copy link
Contributor

📝 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 PactHandle class, but is instead based on a pointer to the struct.

🚨 Breaking Changes

The output type of interactions("All") has been changed to PactInteraction; however, the previous change was not released and therefore this is not a breaking change unless you have been using bleeding edge builds from the main breanch.

🔥 Motivation

Add the ability to iterate over all interactions.

🔨 Test Plan

Unit tests have been updated accordingly.

🔗 Related issues/PRs

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>
@JP-Ellis JP-Ellis self-assigned this Dec 22, 2025
Copilot AI review requested due to automatic review settings December 22, 2025 04:20
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 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 PactInteraction as the base type for all interaction kinds
  • Implemented the Pact class with proper memory management for pointer-based Pact models
  • Added casting methods to convert generic PactInteraction to 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
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 72.41379% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 55%. Comparing base (975414f) to head (c20e33e).
⚠️ Report is 9 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/pact/pact.py 0% 10 Missing ⚠️
pact-python-ffi/src/pact_ffi/__init__.py 87% 6 Missing ⚠️
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     
Flag Coverage Δ
tests 55% <72%> (+<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.

@JP-Ellis JP-Ellis force-pushed the feat/improve-all-iter branch from 5242f1a to 9ca3eed Compare December 22, 2025 04:23
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>
@JP-Ellis JP-Ellis force-pushed the feat/improve-all-iter branch from 9ca3eed to c20e33e Compare December 22, 2025 04:39
@JP-Ellis JP-Ellis merged commit e28be21 into main Dec 22, 2025
62 checks passed
@JP-Ellis JP-Ellis deleted the feat/improve-all-iter branch December 22, 2025 05:02
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.

2 participants