Skip to content

add UpdateTransferRequest class with validation tests#405

Merged
rogelioLpz merged 5 commits into
mainfrom
fix/txn-status
May 27, 2026
Merged

add UpdateTransferRequest class with validation tests#405
rogelioLpz merged 5 commits into
mainfrom
fix/txn-status

Conversation

@julietteceb16
Copy link
Copy Markdown
Contributor

@julietteceb16 julietteceb16 commented May 26, 2026

Note

Low Risk
New optional validation schema and tests only; no runtime auth, payment, or data-path changes in this package.

Overview
Introduces UpdateTransferRequest, a Pydantic request model for patching a transfer’s status to a terminal value only: succeeded or failed. Other TransactionStatus values are rejected at validation time. The type is exported from the public cuenca_validations.types package, and the library version is bumped to 2.1.35.

Tests cover accepted statuses, rejection of intermediate statuses, required status, and BaseRequest’s forbid-extra behavior.

Reviewed by Cursor Bugbot for commit f554ff4. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Added a transfer update request that only accepts final statuses ("succeeded" or "failed") and is now exported at the package level.
  • Tests
    • Added tests validating accepted statuses, rejecting invalid/missing statuses, and forbidding extra fields; errors reference the status field.
  • Chores
    • Package version bumped to 2.1.35

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: efc3720f-3feb-41f9-9a9a-93d7d7a708a6

📥 Commits

Reviewing files that changed from the base of the PR and between 088594f and f554ff4.

📒 Files selected for processing (1)
  • cuenca_validations/version.py
✅ Files skipped from review due to trivial changes (1)
  • cuenca_validations/version.py

Walkthrough

Adds UpdateTransferRequest, a new Pydantic request model with a status field typed as TransactionStatus and validated to accept only TransactionStatus.succeeded or TransactionStatus.failed. Exposes the new model from cuenca_validations.types via import and all, adds pytest coverage for valid/invalid/missing/extra-key scenarios, and updates package version to 2.1.35.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • gmorales96
  • felipao-mx
  • rogelioLpz
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'add UpdateTransferRequest class with validation tests' directly and accurately describes the main changes in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/txn-status

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (e1e0338) to head (f554ff4).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #405   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           16        16           
  Lines         1466      1474    +8     
=========================================
+ Hits          1466      1474    +8     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cuenca_validations/types/__init__.py 100.00% <ø> (ø)
cuenca_validations/types/requests.py 100.00% <100.00%> (ø)
cuenca_validations/version.py 100.00% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e1e0338...f554ff4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@tests/test_requests.py`:
- Around line 107-124: Remove the three redundant tests that assert Pydantic's
built-in validation: delete the functions
test_update_transfer_request_invalid_action,
test_update_transfer_request_missing_action, and
test_update_transfer_request_forbids_extra from tests/test_requests.py; keep the
existing test_update_transfer_request_valid_action (which documents the allowed
Literal values) and ensure no other tests assert Pydantic's internal behavior
for UpdateTransferRequest or BaseRequest.
🪄 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: cf045293-de48-4560-b32c-e032d750daf8

📥 Commits

Reviewing files that changed from the base of the PR and between e1e0338 and 014d7b8.

📒 Files selected for processing (4)
  • cuenca_validations/types/__init__.py
  • cuenca_validations/types/requests.py
  • cuenca_validations/version.py
  • tests/test_requests.py

Comment thread tests/test_requests.py Outdated
Comment on lines +107 to +124
def test_update_transfer_request_invalid_action() -> None:
with pytest.raises(ValidationError) as ex:
UpdateTransferRequest.model_validate({'action': 'cancel'})
assert 'action' in str(ex.value)


def test_update_transfer_request_missing_action() -> None:
with pytest.raises(ValidationError) as ex:
UpdateTransferRequest.model_validate({})
assert 'action' in str(ex.value)


def test_update_transfer_request_forbids_extra() -> None:
with pytest.raises(ValidationError) as ex:
UpdateTransferRequest.model_validate(
{'action': 'approve', 'foo': 'bar'}
)
assert 'Extra inputs are not permitted' in str(ex.value)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Remove tests that validate Pydantic's built-in validators.

These three test functions validate Pydantic's built-in behavior rather than application-specific business logic:

  1. test_update_transfer_request_invalid_action - Tests that Literal['approve', 'reject'] rejects invalid values
  2. test_update_transfer_request_missing_action - Tests that required fields raise ValidationError when missing
  3. test_update_transfer_request_forbids_extra - Tests that extra='forbid' (inherited from BaseRequest) rejects extra keys

As per coding guidelines: "Do not write unit tests specifically for validating the behavior of Pydantic's built-in validators. These are already well-tested by the Pydantic library itself." This is a mandatory rule requiring removal of such tests.

The test_update_transfer_request_valid_action test on lines 100-104 is acceptable as it documents the API contract for valid input values.

♻️ Proposed change to remove redundant tests
-def test_update_transfer_request_invalid_action() -> None:
-    with pytest.raises(ValidationError) as ex:
-        UpdateTransferRequest.model_validate({'action': 'cancel'})
-    assert 'action' in str(ex.value)
-
-
-def test_update_transfer_request_missing_action() -> None:
-    with pytest.raises(ValidationError) as ex:
-        UpdateTransferRequest.model_validate({})
-    assert 'action' in str(ex.value)
-
-
-def test_update_transfer_request_forbids_extra() -> None:
-    with pytest.raises(ValidationError) as ex:
-        UpdateTransferRequest.model_validate(
-            {'action': 'approve', 'foo': 'bar'}
-        )
-    assert 'Extra inputs are not permitted' in str(ex.value)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def test_update_transfer_request_invalid_action() -> None:
with pytest.raises(ValidationError) as ex:
UpdateTransferRequest.model_validate({'action': 'cancel'})
assert 'action' in str(ex.value)
def test_update_transfer_request_missing_action() -> None:
with pytest.raises(ValidationError) as ex:
UpdateTransferRequest.model_validate({})
assert 'action' in str(ex.value)
def test_update_transfer_request_forbids_extra() -> None:
with pytest.raises(ValidationError) as ex:
UpdateTransferRequest.model_validate(
{'action': 'approve', 'foo': 'bar'}
)
assert 'Extra inputs are not permitted' in str(ex.value)
🤖 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_requests.py` around lines 107 - 124, Remove the three redundant
tests that assert Pydantic's built-in validation: delete the functions
test_update_transfer_request_invalid_action,
test_update_transfer_request_missing_action, and
test_update_transfer_request_forbids_extra from tests/test_requests.py; keep the
existing test_update_transfer_request_valid_action (which documents the allowed
Literal values) and ensure no other tests assert Pydantic's internal behavior
for UpdateTransferRequest or BaseRequest.

…us instead of action with corresponding tests
Comment thread cuenca_validations/types/requests.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0e21429. Configure here.

Comment thread tests/test_requests.py Outdated
Comment thread cuenca_validations/types/requests.py Outdated
Comment thread tests/test_requests.py Outdated
@rogelioLpz rogelioLpz merged commit bb508a6 into main May 27, 2026
20 checks passed
@rogelioLpz rogelioLpz deleted the fix/txn-status branch May 27, 2026 18:15
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.

2 participants