Add property-based tests for fraud scorer boundary conditions (#220) - #259
Open
morelucks wants to merge 1 commit into
Open
Add property-based tests for fraud scorer boundary conditions (#220)#259morelucks wants to merge 1 commit into
morelucks wants to merge 1 commit into
Conversation
- Add hypothesis==6.92.1 to requirements.txt for property-based testing - Implement 4 property-based tests using @given strategies: * test_property_score_always_in_valid_range: verifies 0.0 ≤ score ≤ 1.0 * test_property_flagged_invariant: verifies flagged == (score >= 0.5) * test_property_zero_risk_gives_zero_score: verifies zero-risk input * test_property_max_risk_gives_capped_score: verifies max-risk clamping - Add comprehensive boundary tests for all heuristic thresholds: * LARGE_AMOUNT_THRESHOLD boundary cases (at, above, below) * Round-number heuristic edge cases (zero, positive multiples) * Flag threshold boundary (exactly 0.5, just below) * HIGH_RISK_COUNTRIES validation for all countries - All existing tests preserved and continue to pass - Tests verify score clamping behavior when combined factors exceed 1.0 Closes Afro-Pay#220
|
@morelucks is attempting to deploy a commit to the milah's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Description
This PR implements comprehensive property-based tests for the fraud scorer using hypothesis, addressing issue #220.
Changes
Added Dependencies
hypothesis==6.92.1torequirements.txtfor property-based testingProperty-Based Tests (4 new tests)
test_property_score_always_in_valid_range: Verifies the invariant that0.0 ≤ risk_score ≤ 1.0for all possibleTransactionInputcombinationstest_property_flagged_invariant: Verifies thatflagged == (score >= 0.5)holds for all inputstest_property_zero_risk_gives_zero_score: Validates that transactions with no risk factors produce a score of 0.0test_property_max_risk_gives_capped_score: Validates that transactions with all risk factors produce a clamped score of 1.0Boundary Tests (9 new tests)
Testing
All existing tests continue to pass. The new property-based tests use hypothesis strategies to generate diverse test cases covering:
Acceptance Criteria Met
Closes #220