add fraud funds helpers#403
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds three Pydantic models for fraud funds transfer flows: FraudFundsTransferRequest (with CLABE validation and concepto normalization), FraudFundsTransferAcceptedResponse (status fixed to "queued"), and FraudFundsTransferResultEvent (event_type-dependent required fields enforced by a validator). Exposes the types via package exports, adds unit tests for normalization and conditional event payload validation, and bumps package version to 2.1.32.dev2. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #403 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 16 16
Lines 1474 1493 +19
=========================================
+ Hits 1474 1493 +19
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
41ff8e2 to
e4e497e
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cuenca_validations/types/requests.py`:
- Around line 321-326: Remove redundant custom CLABE validator: the
validate_clabe_format field validator duplicates validation provided by the
Clabe type. Delete the `@field_validator-decorated` method validate_clabe_format
and its body from the class, keep the Clabe type import and the field annotated
as clabe: Clabe so Pydantic handles format validation, and ensure no other code
references validate_clabe_format remains.
In `@cuenca_validations/version.py`:
- Line 1: The package version constant __version__ is set to '2.1.32.dev0' but
the PR objective specifies '2.1.31.dev0'; update the __version__ value in
version.py to match the PR objective (set __version__ to '2.1.31.dev0') or
alternatively update the PR description to '2.1.32.dev0' so both the code and PR
intent are consistent, ensuring the published artifact version matches the PR.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e53107db-e349-46f3-acba-81b35adf1c37
📒 Files selected for processing (4)
cuenca_validations/types/__init__.pycuenca_validations/types/requests.pycuenca_validations/version.pytests/test_types.py
d1fedb9 to
668e01a
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cuenca_validations/types/requests.py`:
- Around line 316-319: Several fields (e.g., amount, reason, request_id,
requested_by) use PEP 604 union syntax like `StrictPositiveInt | None` which
breaks on Python 3.9; replace each `X | None` with `Optional[X]` and add `from
typing import Optional` if missing, updating all nine occurrences across the
module (look for other attributes using `| None` and similar patterns) so
annotations match the project's Python 3.9 compatibility and existing style.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 7752b25b-cce1-4d6c-a1ec-f27ed8a64930
📒 Files selected for processing (2)
cuenca_validations/types/requests.pycuenca_validations/version.py
✅ Files skipped from review due to trivial changes (1)
- cuenca_validations/version.py
668e01a to
b457ec9
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
tests/test_types.py (1)
642-652: ⚡ Quick winStrengthen
conceptonormalization coverage with mixed-case input.Current assertion proves whitespace trimming, but it would still pass if lowercasing normalization regresses. Add at least one mixed-case sample to lock normalization behavior.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/test_types.py` around lines 642 - 652, The test currently checks whitespace trimming for the FraudFundsTransferRequest.concepto but doesn't assert normalization of case; update test_fraud_funds_transfer_models to include at least one mixed-case input (e.g., ' FoNdOs FraUdE ') when constructing FraudFundsTransferRequest and assert that request.concepto == 'fondos fraude' (or add a second instance with that mixed-case input and assert normalized lowercased value) to lock the expected lowercasing behavior of the concepto normalization.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cuenca_validations/types/requests.py`:
- Around line 342-365: Remove the custom `@model_validator` validate_payload on
FraudFundsTransferResultEvent and instead define two variant models (e.g.,
FraudFundsTransferSucceeded and FraudFundsTransferFailed) that set event_type =
Literal['fraud_funds_transfer.succeeded'] or
Literal['fraud_funds_transfer.failed'] and declare transaction_id and amount
(for succeeded) and reason_code and message (for failed) as required
(non-Optional) fields; then change the payload type to a
Union[FraudFundsTransferSucceeded, FraudFundsTransferFailed] and use Field(...,
discriminator="event_type") so Pydantic enforces event-specific required fields
automatically.
---
Nitpick comments:
In `@tests/test_types.py`:
- Around line 642-652: The test currently checks whitespace trimming for the
FraudFundsTransferRequest.concepto but doesn't assert normalization of case;
update test_fraud_funds_transfer_models to include at least one mixed-case input
(e.g., ' FoNdOs FraUdE ') when constructing FraudFundsTransferRequest and
assert that request.concepto == 'fondos fraude' (or add a second instance with
that mixed-case input and assert normalized lowercased value) to lock the
expected lowercasing behavior of the concepto normalization.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1706b203-ddad-408e-adc6-04a58c63aa53
📒 Files selected for processing (3)
cuenca_validations/types/requests.pycuenca_validations/version.pytests/test_types.py
✅ Files skipped from review due to trivial changes (1)
- cuenca_validations/version.py
af8c2c7 to
4edc524
Compare
69cc1ef to
15736df
Compare
…dFundsTransferAcceptedResponse, and FraudFundsTransferResultEvent models with validation logic and tests.
…models to use union types for optional fields and update the validate_payload method to return Self.
…and FraudFundsTransferResultEvent models to use Optional for fields, removing validation logic for CLABE format.
…ired fields, and update related tests accordingly.
… response classes, while removing deprecated ones. Update related tests accordingly.
47a0740 to
85f5438
Compare
| class FraudFundsTransferReasonCode(str, Enum): | ||
| user_not_found = 'USER_NOT_FOUND' | ||
| user_not_fraud_blocked = 'USER_NOT_FRAUD_BLOCKED' | ||
| insufficient_funds = 'INSUFFICIENT_FUNDS' | ||
| clabe_invalid = 'CLABE_INVALID' | ||
| internal_error = 'INTERNAL_ERROR' |
Summary by CodeRabbit
New Features
Tests
Chores