- 
                Notifications
    
You must be signed in to change notification settings  - Fork 145
 
feat: add consumer_version method #1315
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
base: main
Are you sure you want to change the base?
Conversation
          Codecov Report❌ Patch coverage is  
 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     
 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry.  | 
    
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 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_versionmethod with full type annotations and detailed documentation - Deprecates the existing 
consumer_versionsmethod 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]>
cb5917a    to
    db2972d      
    Compare
  
    
📝 Summary
Add a new properly typed and documented
consumer_versionmethod to the broker selector builder class. This now allows for calls like:For more information on selectors, so the new method docs and the Pact docs.
🚨 Breaking Changes
The old
consumer_versionsmethod 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_versionsmethod 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