Skip to content

Conversation

@gmorales96
Copy link
Contributor

@gmorales96 gmorales96 commented Jul 29, 2025

Summary by CodeRabbit

  • New Features

    • Added support for updating user pronouns.
  • Bug Fixes

    • Simplified user creation and update interfaces by removing several optional fields.
  • Tests

    • Updated test data and scenarios to reflect changes in user attributes and API responses.
    • Enhanced test coverage for user updates, including new fields and updated user profiles.
  • Chores

    • Updated dependency version for improved validations.
    • Bumped client version to 2.1.9.

@gmorales96 gmorales96 requested a review from alexviquez as a code owner July 29, 2025 17:55
@coderabbitai
Copy link

coderabbitai bot commented Jul 29, 2025

"""

Walkthrough

This change updates the user management API by removing several parameters (phone_number, email_address, status, required_level, terms_of_service, verification_id) from the User.create and User.update methods, and changing the address parameter type to AddressRequest. The pronouns field is added to the User.update method. Test fixtures, test cassettes, and test logic are updated to align with the new method signatures and expected API behavior. The dependency on cuenca-validations is incremented to version 2.1.14. Additionally, the client version is bumped to 2.1.9. Test data reflecting user profiles, verification IDs, and timestamps are also updated accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Possibly related PRs

  • Add fiscal_regime_code field to User #425: Modifies the User class and its update method by adding a new optional fiscal_regime_code parameter, which overlaps with the changes in this PR that also alter the User.update method signature.
  • update cuenca-validations #406: Updates versioning and dependencies, including cuenca-validations, similar to this PR's version bump and dependency update.

Suggested reviewers

  • alexviquez
  • rogelioLpz
  • felipao-mx
    """

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd1331 and a6305c7.

📒 Files selected for processing (2)
  • cuenca/version.py (1 hunks)
  • requirements.txt (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • requirements.txt
  • cuenca/version.py
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fixs-onboarding

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@codecov
Copy link

codecov bot commented Jul 29, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #426   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           54        54           
  Lines         1180      1180           
=========================================
  Hits          1180      1180           
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/resources/users.py 100.00% <100.00%> (ø)
cuenca/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 21690e1...a6305c7. 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

@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: 3

🧹 Nitpick comments (2)
tests/resources/cassettes/test_session_create.yaml (1)

142-146: Optional: add a positive-case for pronouns

pronouns is always recorded as null. A dedicated test that sets and retrieves a non-null value would prove the new field is wired end-to-end and survives PATCH round-trips.

tests/resources/cassettes/test_user_update.yaml (1)

3-6: Consider adding non-null pronouns scenario

As with the session cassette, only null pronouns are covered. A positive example would harden regression detection for that field.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21690e1 and 748b136.

📒 Files selected for processing (7)
  • cuenca/resources/users.py (2 hunks)
  • requirements.txt (1 hunks)
  • tests/conftest.py (2 hunks)
  • tests/resources/cassettes/test_session_create.yaml (1 hunks)
  • tests/resources/cassettes/test_user_update.yaml (1 hunks)
  • tests/resources/test_sessions.py (2 hunks)
  • tests/resources/test_users.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py

⚙️ CodeRabbit Configuration File

**/*.py: Enforce Relative Imports for Internal Modules

Ensure that any imports referencing internal modules use relative paths. However, if modules reside in the main module directories (for example /src or /library_or_app_name) —and relative imports are not feasible—absolute imports are acceptable. Additionally, if a module is located outside the main module structure (for example, in /tests or /scripts at a similar level), absolute imports are also valid.

Examples and Guidelines:

  1. If a module is in the same folder or a subfolder of the current file, use relative imports. For instance: from .some_module import SomeClass
  2. If the module is located under /src or /library_or_app_name and cannot be imported relatively, absolute imports are allowed (e.g., from library_or_app_name.utilities import helper_method).
  3. If a module is outside the main module directories (for example, in /tests, /scripts, or any similarly placed directory), absolute imports are valid.
  4. External (third-party) libraries should be imported absolutely (e.g., import requests).

**/*.py:
Rule: Enforce Snake Case in Python Backend

  1. New or Modified Code: Use snake_case for all variables, functions, methods, and class attributes.
  2. Exceptions (Pydantic models for API responses):
    • Primary fields must be snake_case.
    • If older clients expect camelCase, create a computed or alias field that references the snake_case field.
    • Mark any camelCase fields as deprecated or transitional.

Examples

Invalid:

class CardConfiguration(BaseModel):
    title: str
    subTitle: str  # ❌ Modified or new field in camelCase

Valid:

class CardConfiguration(BaseModel):
    title: str
    subtitle: str  # ✅ snake_case for new/modified field

    @computed_field
    def subTitle(self) -> str:  # camelCase allowed only for compatibility
        return self.subtitle

Any direct use of camelCase in new or updated code outside of these exceptions should be flagged.

`*...

Files:

  • tests/resources/test_sessions.py
  • tests/resources/test_users.py
  • tests/conftest.py
  • cuenca/resources/users.py
**/conftest.py

⚙️ CodeRabbit Configuration File

**/conftest.py: Always use the fastapi.testclient.TestClient as a context manager in pytest fixtures to ensure proper cleanup:

@pytest.fixture
def client():
    from myapp.app import app
    with TestClient(app) as client:
        yield client

❌ Incorrect Pattern (Flag This):

@pytest.fixture
def client():
    from myapp.app import app
    return TestClient(app)  # Missing context manager

Severity: CRITICAL (Not a Nitpick)
This is a critical issue that must be fixed, not a nitpick or style suggestion. Failing to use the context manager pattern can cause:

Closed event loops in tests with multiple requests to the same endpoint, breaking subsequent test execution

Files:

  • tests/conftest.py
🔇 Additional comments (12)
requirements.txt (1)

2-2: Verify that using a development version is intentional.

The cuenca-validations package has been updated to a development pre-release version (2.1.14.dev1). Development versions can introduce instability and should typically be avoided in production environments.

Please confirm this is intentional for the current development phase and ensure it's updated to a stable release before production deployment.

tests/resources/test_sessions.py (2)

2-2: LGTM!

The import addition for Profession is appropriate for the updated test logic.


39-40: LGTM!

The test logic has been appropriately updated to use the profession field instead of email_address, which aligns with the API refactoring that removed email parameters from the User.update method.

tests/resources/test_users.py (3)

5-5: LGTM!

The import addition for SATRegimeCode is appropriate for the updated test logic that uses this enum.


32-32: LGTM!

The user ID has been updated to align with the test data changes.


33-36: LGTM!

The test changes appropriately reflect the API refactoring:

  • Removal of phone_number and govt_id parameters from User.update
  • Addition of fiscal_regime_code parameter using the SATRegimeCode enum

These changes are consistent with the simplified user update interface.

tests/conftest.py (2)

39-40: LGTM!

The fixture data updates for birth date and state are appropriate for the test data alignment.


56-60: LGTM!

The fixture updates appropriately reflect the API refactoring:

  • Removal of direct phone_number and email_address fields
  • Replacement with phone_verification_id and email_verification_id parameters
  • Updated postal_code_id for test data consistency

These changes align with the simplified User.create interface that now uses verification IDs instead of direct contact information.

cuenca/resources/users.py (3)

19-19: LGTM!

The import change from TOSRequest to AddressRequest aligns with the updated parameter types in the create and update methods.


106-123: LGTM!

The User.create method has been appropriately simplified:

  • Parameter type changed from Address to AddressRequest for better request modeling
  • Removed complex parameters that were likely causing interface bloat
  • Maintains essential functionality with curp, profession, address, and verification IDs

The simplified interface should be easier to use and maintain.


125-158: LGTM!

The User.update method changes are well-structured:

  • Parameter type changed from Address to AddressRequest for consistency
  • Added pronouns parameter to support inclusive user profiles
  • Maintains all essential update functionality
  • Proper integration of the new parameter into the UserUpdateRequest

The changes enhance the API while maintaining a clean interface.

tests/resources/cassettes/test_user_update.yaml (1)

3-6: Good alignment with new update signature

The expanded PATCH body mirrors the freshly supported fields (fiscal_regime_code, pronouns, etc.). Looks correct.

@gmorales96 gmorales96 changed the title Update requirements and refactor User class Enhance onboarding Jul 29, 2025
@gmorales96 gmorales96 requested a review from rogelioLpz July 30, 2025 17:52
@rogelioLpz rogelioLpz enabled auto-merge (squash) August 1, 2025 16:32
@rogelioLpz rogelioLpz merged commit 432a69e into main Aug 1, 2025
20 of 39 checks passed
@rogelioLpz rogelioLpz deleted the fixs-onboarding branch August 1, 2025 16:36
@coderabbitai coderabbitai bot mentioned this pull request Sep 11, 2025
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.

3 participants