Skip to content

Conversation

@JP-Ellis
Copy link
Contributor

@JP-Ellis JP-Ellis commented Oct 31, 2025

📝 Summary

Add a new properly typed and documented consumer_version method to the broker selector builder class. This now allows for calls like:

verifier = (
    Verifier(...)
    .broker_source(..., selector=True)
    .consumer_version(deployed_or_released=True)
    .consumer_version(branch="main")
    .build()
)

For more information on selectors, so the new method docs and the Pact docs.

🚨 Breaking Changes

The old consumer_versions method would replace any previous calls to it. This has been changed so that successive calls extend the selectors.

I doubt anyone would rely on this behaviour, and therefore will not produce a major version tag; however, I am documenting this here in case you relied on this behaviour.

🔥 Motivation

The old consumer_versions method required used to pass in a JSON-serialised dictionary, which was untyped. This made it difficult for people to discover information about consumer version selectors.

🔨 Test Plan

Unit tests updated.

🔗 Related issues/PRs

@JP-Ellis JP-Ellis self-assigned this Oct 31, 2025
Copilot AI review requested due to automatic review settings October 31, 2025 02:34
@codecov
Copy link

codecov bot commented Oct 31, 2025

Codecov Report

❌ Patch coverage is 29.41176% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 52%. Comparing base (da29864) to head (db2972d).
⚠️ Report is 3 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/pact/verifier.py 29% 12 Missing ⚠️
Additional details and impacted files
@@         Coverage Diff          @@
##           main   #1315   +/-   ##
====================================
- Coverage    52%     52%   -1%     
====================================
  Files        32      31    -1     
  Lines      3744    3702   -42     
====================================
- Hits       1967    1930   -37     
+ Misses     1777    1772    -5     
Flag Coverage Δ
tests 52% <29%> (-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.

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 introduces a new consumer_version method to the broker selector builder class, providing a properly typed and documented interface for consumer version selectors. This replaces the need to manually construct JSON-serialised dictionaries when using consumer version selectors.

  • Adds a comprehensive consumer_version method with full type annotations and detailed documentation
  • Deprecates the existing consumer_versions method in favor of the new approach
  • Updates the broker source builder to handle both string patterns and dictionary selectors

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/pact/verifier.py Adds the new consumer_version method with comprehensive parameter mapping and camelCase conversion, deprecates consumer_versions, and updates the build method to serialize dictionary selectors
tests/test_verifier.py Adds comprehensive parametrized tests covering various selector scenarios including camelCase conversion, multiple selectors, and None value exclusion

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The new `consumer_version` replaces the (now deprecated)
`consumer_versions` method within the broker source selector class. This
replaces the explicit JSON-serialisation of an untyped dictionary into a
much more structured call with documented keyword argument.

Signed-off-by: JP-Ellis <[email protected]>
@JP-Ellis JP-Ellis force-pushed the feat/add-consumer-version-method branch from cb5917a to db2972d Compare October 31, 2025 02:41
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 ConsumerVersionSelector Class

3 participants