fix(contracts): emit predefinedExpectations from availableExpectations (#309)#310
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Restores ContractExpectations.predefinedExpectations emission (alongside availableExpectations) so the OpenAEV platform can pre-fill default expectations again after the earlier rename to availableExpectations.
Changes:
- Added
predefinedExpectationsback toContractExpectationsand derive it in__post_init__fromexpectation_is_predefined=Truewhen not explicitly provided. - Added unit tests validating derivation behavior, explicit predefined lists, and the no-flag case.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
pyoaev/contracts/contract_config.py |
Reintroduces predefinedExpectations and adds derivation logic in ContractExpectations.__post_init__. |
test/contracts/test_contract_expectations.py |
Adds unit tests covering predefined expectation derivation and serialization. |
test/contracts/__init__.py |
Package marker for the new test.contracts test module. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…#309) Derive predefinedExpectations from the expectation_is_predefined flags only when the caller did not provide the list, so an explicit empty list can suppress pre-fill. Also drop a needless getattr fallback, add a test for the explicit-empty override and normalize the test file to LF.
Member
Author
|
Review-and-fix pass complete:
Note: I cannot approve this PR since I am its author - it needs an approving review from another maintainer to unblock merge. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #309
Summary
Predefined Detection / Prevention (and other) expectations stopped pre-filling when creating an atomic testing or inject: the expectations picker no longer proposed any defaults.
Commit 3ca50c3 (#306) renamed
ContractExpectations.predefinedExpectationstoavailableExpectationsand introduced a per-expectationexpectation_is_predefinedflag. But the OpenAEV platform pre-fills expectations from the field-levelpredefinedExpectationsarray (the frontend inject form readspredefinedExpectationsfor the defaults andavailableExpectationsfor the picker); the per-expectation flag is not consumed. After #306 pyoaev emitted onlyavailableExpectations, sopredefinedExpectationswas always empty and nothing was pre-filled.This is on unreleased
main(not in 2.260717.0), so it would ship as a regression on the next release and break predefined expectations for every Python injector.Change
ContractExpectationsnow carries bothavailableExpectations(the full selectable set) andpredefinedExpectations(the defaults the platform pre-fills).predefinedExpectationsdefaults toNoneas the "not provided" sentinel: when the caller does not pass it,__post_init__derives it from the expectations flaggedexpectation_is_predefined=True, so the existing single-list API keeps working end-to-end. Passing an explicit list (including an empty one) overrides the derivation, and the serialized contract always emits an array.test/contracts/covering the derivation, an explicit predefined list, the explicit-empty-list override, and the no-flag case.Test plan
pytest test/contracts/passes (4 tests).black/isortclean.EnhancedJSONEncoderemits apredefinedExpectationsarray matching the flagged expectations.