Skip to content

Conversation

@vrajpatelll
Copy link
Collaborator

@vrajpatelll vrajpatelll commented Jun 28, 2025

Pull Request: User Service API Alignment & Improvements

Summary of changes:

  • Standardized all user API responses to use id and imageUrl fields.
  • Date fields (createdAt, updatedAt) now use datetime in backend models and are serialized as ISO 8601 strings in API responses.
  • Updated Pydantic models and service logic for field and type consistency.
  • Improved error response structure to match documentation.
  • Refactored and updated all user service and route tests for new field names and types.
  • Clarified date handling in API documentation.

Result:
Backend, tests, and docs for user service are now fully aligned and consistent with the public API contract.

Summary by CodeRabbit

  • New Features

    • Added support for updating the user's currency in profile updates.
  • Bug Fixes

    • Standardized error responses to include structured error codes and messages.
    • Ensured user profile responses use camelCase keys and ISO 8601 formatted date strings.
  • Documentation

    • Updated user service documentation to clarify field naming conventions and date formats in API responses.
  • Tests

    • Refactored user route and service tests for consistency with new response formats and to use synchronous test clients.

@netlify
Copy link

netlify bot commented Jun 28, 2025

Deploy Preview for splitwizer canceled.

Name Link
🔨 Latest commit 36bed89
🔍 Latest deploy log https://app.netlify.com/projects/splitwizer/deploys/6861463a7cade10008e5e601

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 28, 2025

Walkthrough

The changes standardize user-related API response schemas and error formats, update the transformation and update logic in the user service, and refactor tests to use synchronous FastAPI TestClient with updated data formats. Documentation is revised for naming consistency and clarification of date field serialization.

Changes

Files/Paths Change Summary
backend/app/user/routes.py Error responses now use structured dictionaries with "error" and "message" fields instead of plain strings.
backend/app/user/schemas.py Removed Pydantic field aliasing and default value configuration; added optional currency field to update request schema.
backend/app/user/service.py Updated user document transformation to use camelCase keys and ISO 8601 date strings; update logic now restricts allowed fields and sets updated timestamp; relaxed delete success condition.
backend/tests/user/test_user_routes.py Refactored tests to use synchronous FastAPI TestClient; mocks and assertions updated for camelCase keys, ISO date strings, and structured error responses.
backend/tests/user/test_user_service.py Tests now use fixed ISO 8601 datetime strings and camelCase keys; updated assertions for new schema and date handling; added tests for date transformations.
docs/user-service.md Documentation updated for camelCase keys, ISO 8601 date string clarification, and improved schema consistency notes.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant UserService
    participant Database

    Client->>API: PATCH /users/me (update profile)
    API->>UserService: update_user_profile(user_id, update_fields)
    UserService->>Database: Update user with allowed fields (name, imageUrl, currency)
    Database-->>UserService: Updated user document
    UserService-->>API: Transformed user data (camelCase, ISO dates)
    API-->>Client: 200 OK with updated user profile

    alt No update fields
        API-->>Client: 400 Bad Request {"detail": {"error": "...", "message": "..."}}
    end

    alt User not found
        API-->>Client: 404 Not Found {"detail": {"error": "...", "message": "..."}}
    end
Loading

Possibly related PRs

  • Devasy23/splitwiser#11: Adds the initial user service endpoints and route handlers, which are directly modified and enhanced in this PR.

Poem

A hop and a skip, we tidy our code,
CamelCase fields now lighten the load.
Dates in ISO, errors neat and clear,
User routes and tests—refined, sincere!
With schemas aligned and docs up to date,
This bunny declares: our API’s great!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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 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 Jun 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.53%. Comparing base (6b31ff1) to head (36bed89).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #25      +/-   ##
==========================================
+ Coverage   71.33%   71.53%   +0.19%     
==========================================
  Files          19       19              
  Lines        1591     1602      +11     
  Branches      156      158       +2     
==========================================
+ Hits         1135     1146      +11     
  Misses        456      456              
Flag Coverage Δ
api 71.53% <100.00%> (+0.19%) ⬆️
backend 71.53% <100.00%> (+0.19%) ⬆️
python 71.53% <100.00%> (+0.19%) ⬆️

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

Files with missing lines Coverage Δ
backend/app/user/routes.py 100.00% <100.00%> (ø)
backend/app/user/schemas.py 100.00% <100.00%> (ø)
backend/app/user/service.py 85.71% <100.00%> (+3.89%) ⬆️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
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

🧹 Nitpick comments (6)
backend/app/user/routes.py (1)

30-34: Fix formatting issue and consider dependency injection pattern.

There are two issues to address:

  1. Missing blank line before function definition (static analysis)
  2. Function call in argument defaults (static analysis)

Apply this diff to fix the formatting:

+

 @router.delete("/me", response_model=DeleteUserResponse)

For the dependency injection, the current pattern is acceptable in FastAPI, but if you want to follow the static analysis suggestion, you could refactor like this:

-async def delete_user_account(current_user: Dict[str, Any] = Depends(get_current_user)):
+async def delete_user_account(current_user: Dict[str, Any] = Depends(get_current_user)):

Actually, the B008 warning about Depends in defaults is a false positive for FastAPI - this is the standard FastAPI pattern and is intentional.

backend/tests/user/test_user_service.py (1)

3-3: Remove unused import to clean up test file.

The get_database import is flagged as unused by static analysis and should be removed.

Apply this diff:

-from app.database import get_database
backend/tests/user/test_user_routes.py (4)

6-6: Remove unused import.

The datetime class from the datetime module is imported but never used in the file.

-from datetime import datetime, timedelta
+from datetime import timedelta

27-29: Remove unused variable.

The variable iso_date3 is defined but never used within the fixture scope.

 iso_date = "2023-01-01T00:00:00Z"
 iso_date2 = "2023-01-02T00:00:00Z"
-iso_date3 = "2023-01-03T00:00:00Z"

93-99: Fix unused variable in test.

The iso_date3 variable is defined locally but the mock uses a different variable name in line 99. This creates an inconsistency.

 iso_date = "2023-01-01T00:00:00Z"
-iso_date3 = "2023-01-03T00:00:00Z"
+iso_date_updated = "2023-01-03T00:00:00Z"
 update_payload = {"name": "Only Name Updated"}
 mocker.patch("app.user.service.user_service.update_user_profile", return_value={
     "id": TEST_USER_ID, "name": "Only Name Updated", "email": TEST_USER_EMAIL,
     "imageUrl": None, "currency": "USD",
-    "createdAt": iso_date, "updatedAt": iso_date3
+    "createdAt": iso_date, "updatedAt": iso_date_updated
 })

53-140: Address PEP 8 formatting issues.

Multiple test functions are missing the required two blank lines before function definitions as per PEP 8 standards.

@pytest.fixture(scope="module")
def auth_headers():
    token = create_access_token(
        data={"sub": TEST_USER_EMAIL, "_id": TEST_USER_ID},
        expires_delta=timedelta(minutes=15)
    )
    return {"Authorization": f"Bearer {token}"}

+
@pytest.fixture(autouse=True, scope="function")
async def setup_test_user(mocker):
    # ... rest of fixture
    yield

+
# --- Tests for GET /users/me ---

+
def test_get_current_user_profile_success(client: TestClient, auth_headers: dict, mocker):

Apply similar spacing before all other test function definitions.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5d6687c and a59f68b.

📒 Files selected for processing (6)
  • backend/app/user/routes.py (2 hunks)
  • backend/app/user/schemas.py (1 hunks)
  • backend/app/user/service.py (3 hunks)
  • backend/tests/user/test_user_routes.py (2 hunks)
  • backend/tests/user/test_user_service.py (5 hunks)
  • docs/user-service.md (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
backend/app/user/routes.py (3)
backend/app/user/service.py (2)
  • update_user_profile (47-62)
  • delete_user (64-71)
backend/app/user/schemas.py (1)
  • DeleteUserResponse (19-21)
backend/app/auth/security.py (1)
  • get_current_user (102-119)
backend/tests/user/test_user_service.py (2)
backend/app/database.py (1)
  • get_database (31-37)
backend/app/user/service.py (1)
  • transform_user_document (14-36)
🪛 Flake8 (7.2.0)
backend/app/user/routes.py

[error] 29-29: expected 2 blank lines, found 1

(E302)

backend/app/user/service.py

[error] 22-22: expected 1 blank line before a nested definition, found 0

(E306)

backend/app/user/schemas.py

[error] 5-5: expected 2 blank lines, found 1

(E302)

backend/tests/user/test_user_service.py

[error] 3-3: 'app.database.get_database' imported but unused

(F401)


[error] 82-82: expected 2 blank lines, found 1

(E302)

backend/tests/user/test_user_routes.py

[error] 6-6: 'datetime.datetime' imported but unused

(F401)


[error] 12-12: expected 2 blank lines, found 1

(E302)


[error] 29-29: local variable 'iso_date3' is assigned to but never used

(F841)


[error] 53-53: expected 2 blank lines, found 1

(E302)


[error] 65-65: expected 2 blank lines, found 1

(E302)


[error] 74-74: expected 2 blank lines, found 1

(E302)


[error] 91-91: expected 2 blank lines, found 1

(E302)


[error] 110-110: expected 2 blank lines, found 1

(E302)


[error] 116-116: expected 2 blank lines, found 1

(E302)


[error] 126-126: expected 2 blank lines, found 1

(E302)


[error] 134-134: expected 2 blank lines, found 1

(E302)

🪛 Ruff (0.11.9)
backend/app/user/routes.py

30-30: Do not perform function call Depends in argument defaults; instead, perform the call within the function, or read the default from a module-level singleton variable

(B008)

backend/tests/user/test_user_service.py

3-3: app.database.get_database imported but unused

Remove unused import: app.database.get_database

(F401)

backend/tests/user/test_user_routes.py

6-6: datetime.datetime imported but unused

Remove unused import: datetime.datetime

(F401)


29-29: Local variable iso_date3 is assigned to but never used

Remove assignment to unused variable iso_date3

(F841)

🪛 GitHub Check: codecov/patch
backend/app/user/service.py

[warning] 24-24: backend/app/user/service.py#L24
Added line #L24 was not covered by tests


[warning] 26-26: backend/app/user/service.py#L26
Added line #L26 was not covered by tests

🪛 Pylint (3.3.7)
backend/app/user/schemas.py

[refactor] 5-5: Too few public methods (0/2)

(R0903)

🔇 Additional comments (22)
backend/app/user/routes.py (3)

13-13: LGTM! Structured error response improves API consistency.

The change from a plain string to a structured JSON object with error and message fields provides better error handling for API consumers.


23-23: LGTM! Consistent error response format.

Good standardization of the validation error response format to match the other endpoints.


26-26: LGTM! Error response format aligns with API standards.

The structured error format maintains consistency across all user endpoints.

backend/app/user/service.py (5)

29-29: LGTM! Field name standardization is consistent.

The change from _id to id aligns with the API standardization goals and matches the schema updates.


32-32: LGTM! Backwards-compatible field name transition.

The fallback logic user.get("imageUrl") or user.get("avatar") provides good backwards compatibility during the transition period.


34-35: LGTM! Date field standardization with proper fallback.

The conversion to camelCase and ISO 8601 strings is consistent, and the fallback to created_at for updatedAt when not present is appropriate.


53-55: Excellent security improvement with field filtering.

The allowlist approach for update fields (name, imageUrl, currency) prevents unauthorized field modifications and aligns with the schema updates.


71-71: Confirm delete logic change in user service

I wasn’t able to find any other delete_one() checks in the codebase to compare against, so please verify that switching from

result.deleted_count == 1

to

result.deleted_count > 0

in backend/app/user/service.py (line 71) was intentional. Although delete_one() only ever returns 0 or 1, this looser check could mask unexpected behavior—let me know if this aligns with the intended delete semantics.

docs/user-service.md (2)

39-39: LGTM! Field name standardization in documentation.

The change from image_url to imageUrl aligns with the camelCase standardization implemented in the service layer.


41-47: Excellent clarification of date field handling.

The inline comments and note clearly explain:

  1. API responses use ISO 8601 strings
  2. Backend frameworks may parse them as datetime objects
  3. Backend stores as datetime but serializes as strings

This documentation will help developers understand the data transformation process.

backend/app/user/schemas.py (4)

1-1: LGTM! EmailStr import aligns with schema requirements.

Good addition of the EmailStr import to ensure proper email validation in the schemas.


6-6: LGTM! Schema simplification with service layer transformation.

Removing the _id alias makes sense since the service layer now handles the _id to id transformation in transform_user_document.


9-9: LGTM! Consistent field name standardization.

Removing the avatar alias aligns with the service layer change to use imageUrl directly.


17-17: LGTM! Currency field addition completes the update schema.

The optional currency field aligns with the allowlist filtering in the service layer's update_user_profile method.

backend/tests/user/test_user_service.py (4)

30-35: Excellent improvement with fixed datetime constants.

Using fixed datetime values instead of datetime.now() makes tests deterministic and more reliable. The ISO string representations are properly formatted with 'Z' suffix for UTC.


41-41: LGTM! Test data aligns with schema changes.

The field name updates (avatarimageUrl, _idid, datetime objects → ISO strings) correctly reflect the service layer transformations.

Also applies to: 48-48, 51-51, 53-55


71-78: LGTM! Comprehensive test coverage for minimal user data.

The test properly validates the fallback behavior for optional fields and default values (currency: "USD", imageUrl: None).


134-134: LGTM! Test assertions updated for new field names.

The assertions correctly check for id instead of _id and validate the ISO string format for updatedAt.

Also applies to: 153-154

backend/tests/user/test_user_routes.py (4)

12-15: Good refactor to synchronous testing.

The change from httpx.AsyncClient to fastapi.testclient.TestClient simplifies the test setup and aligns with the synchronous test approach used throughout the file.


30-38: Verify field name consistency with backend changes.

The mock data correctly uses the new standardized field names (id, imageUrl, createdAt, updatedAt) and ISO 8601 date format, which aligns with the PR objectives of standardizing API responses.


58-63: Good assertions for new field names and date format.

The test correctly validates the new camelCase field names and ensures datetime fields are serialized as ISO 8601 strings ending with "Z".


70-70: Error response format verified

The test’s assertion exactly matches the routes’ implementation of error responses ({"detail": {"error": "...", "message": "..."}}), so no changes are needed.

Comment on lines 21 to 27
# Ensure ISO 8601 string for dates
def iso(dt):
if not dt:
return None
if isinstance(dt, str):
return dt
return dt.isoformat().replace("+00:00", "Z") if dt.tzinfo else dt.isoformat()
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 28, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

ISO date conversion logic needs refinement and test coverage.

The iso function handles date-to-string conversion but has several concerns:

  1. Lines 24 and 26 are not covered by tests (static analysis)
  2. Missing blank line before nested function definition
  3. The timezone handling logic could be more robust

Apply this diff to fix formatting and improve the logic:

-        # Ensure ISO 8601 string for dates
-        def iso(dt):
+        # Ensure ISO 8601 string for dates
+        
+        def iso(dt):
             if not dt:
                 return None
             if isinstance(dt, str):
                 return dt
-            return dt.isoformat().replace("+00:00", "Z") if dt.tzinfo else dt.isoformat()
+            if hasattr(dt, 'isoformat'):
+                return dt.isoformat().replace("+00:00", "Z") if dt.tzinfo else dt.isoformat() + "Z"
+            return str(dt)  # Fallback for unexpected types

The test coverage issues should be addressed by adding tests for edge cases like string inputs and timezone-naive datetime objects.


🏁 Script executed:

#!/bin/bash
# Search for the iso function and its usages in the codebase
rg -n "def iso" -n backend/app
rg -n "iso(" -n backend/app
# Search for any tests covering iso or date conversion
rg -n "iso(" -n tests

Length of output: 256


🏁 Script executed:

#!/bin/bash
# Inspect the transform_user_document implementation around the iso function
rg -n "def transform_user_document" -n backend/app/user/service.py
sed -n '1,200p' backend/app/user/service.py | sed -n '1,80p'

# Search for any tests invoking iso or transform_user_document
rg -nF "iso(" -n tests || echo "No iso usages in tests"
rg -nF "transform_user_document" -n tests || echo "No transform_user_document usages in tests"

Length of output: 3076


Refine ISO date conversion logic and add comprehensive tests

Please update the nested iso helper in backend/app/user/service.py to improve readability, ensure consistent UTC output, and cover all branches with unit tests:

  • Insert a blank line before the def iso(dt): definition (PEP-8 spacing).
  • Replace the existing conversion logic with a UTC-normalizing approach that handles both naive and tz-aware datetimes, falling back to str(dt) on error.
  • Add new tests under tests/ to cover:
    dt=None → returns None
    dt as str → returns original string
    • naive datetime → suffixed with “Z”
    • aware datetime (UTC and non-UTC) → converted to UTC “Z”
    • unexpected types → converted via str(dt)

Suggested diff:

--- a/backend/app/user/service.py
+++ b/backend/app/user/service.py
@@ -20,8 +20,11 @@ class UserService:
         # Ensure ISO 8601 string for dates
-        def iso(dt):
+        
+        def iso(dt):
             if not dt:
                 return None
             if isinstance(dt, str):
                 return dt
-            return dt.isoformat().replace("+00:00", "Z") if dt.tzinfo else dt.isoformat()
+            # Normalize to UTC and append 'Z'
+            try:
+                dt_utc = dt.astimezone(timezone.utc) if dt.tzinfo else dt.replace(tzinfo=timezone.utc)
+                return dt_utc.isoformat().replace("+00:00", "Z")
+            except AttributeError:
+                return str(dt)

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 24-24: backend/app/user/service.py#L24
Added line #L24 was not covered by tests


[warning] 26-26: backend/app/user/service.py#L26
Added line #L26 was not covered by tests

🪛 Flake8 (7.2.0)

[error] 22-22: expected 1 blank line before a nested definition, found 0

(E306)

🤖 Prompt for AI Agents
In backend/app/user/service.py around lines 21 to 27, add a blank line before
the iso(dt) function definition to comply with PEP-8 spacing. Refactor the iso
function to normalize all datetime inputs to UTC, converting naive datetimes by
assuming UTC, converting aware datetimes to UTC, and formatting them with a "Z"
suffix. If conversion fails, return str(dt). Also, create comprehensive unit
tests in the tests/ directory covering all cases: None input returns None,
string input returns unchanged, naive datetime returns ISO format with "Z",
aware datetime (both UTC and non-UTC) converts to UTC with "Z", and unexpected
types convert to string.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed.

Copy link
Contributor

Choose a reason for hiding this comment

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

@vrajpatelll Thank you for addressing the ISO date conversion logic issues! I can see the iso function now includes proper spacing, robust UTC normalization, and comprehensive error handling as suggested. Great work!


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

Copy link
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: 0

🧹 Nitpick comments (1)
backend/tests/user/test_user_service.py (1)

105-141: Excellent comprehensive datetime transformation test coverage.

These tests thoroughly verify the robust datetime handling for various edge cases including None values, string inputs, naive/aware datetimes, and timezone conversions.

Minor formatting fix needed:

-def test_transform_user_document_iso_unexpected_type():
-    class Dummy: pass
+def test_transform_user_document_iso_unexpected_type():
+    class Dummy:
+        pass
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a59f68b and 732d049.

📒 Files selected for processing (2)
  • backend/app/user/service.py (3 hunks)
  • backend/tests/user/test_user_service.py (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/app/user/service.py
🧰 Additional context used
🧬 Code Graph Analysis (1)
backend/tests/user/test_user_service.py (2)
backend/app/database.py (1)
  • get_database (31-37)
backend/app/user/service.py (1)
  • transform_user_document (14-42)
🪛 Ruff (0.11.9)
backend/tests/user/test_user_service.py

3-3: app.database.get_database imported but unused

Remove unused import: app.database.get_database

(F401)


136-136: Multiple statements on one line (colon)

(E701)

🪛 Flake8 (7.2.0)
backend/tests/user/test_user_service.py

[error] 3-3: 'app.database.get_database' imported but unused

(F401)


[error] 82-82: expected 2 blank lines, found 1

(E302)


[error] 102-102: expected 2 blank lines, found 1

(E302)


[error] 105-105: expected 2 blank lines, found 1

(E302)


[error] 110-110: expected 2 blank lines, found 1

(E302)


[error] 115-115: expected 2 blank lines, found 1

(E302)


[error] 121-121: expected 2 blank lines, found 1

(E302)


[error] 128-128: expected 2 blank lines, found 1

(E302)


[error] 135-135: expected 2 blank lines, found 1

(E302)


[error] 136-136: multiple statements on one line (colon)

(E701)

🪛 Pylint (3.3.7)
backend/tests/user/test_user_service.py

[refactor] 136-136: Too few public methods (0/2)

(R0903)

🔇 Additional comments (4)
backend/tests/user/test_user_service.py (4)

3-35: LGTM! Deterministic datetime constants improve test reliability.

The fixed datetime constants with corresponding ISO string representations are excellent for ensuring deterministic test behavior. The static analysis warning about unused get_database import is a false positive since it's used in the mock fixture at line 23.


37-55: Test data correctly reflects the schema standardization.

The updates to use imageUrl instead of avatar, id instead of _id, and ISO string representations for datetime fields properly align with the API standardization objectives.


59-101: Existing tests properly updated for new schema.

The updates maintain comprehensive test coverage while correctly adapting to the new field names and ISO date formatting requirements.


144-232: Service method tests properly updated for new schema.

The tests correctly verify the service behavior with updated field names and deterministic datetime handling. The mock setup and assertions properly reflect the schema changes.

@Devasy Devasy self-requested a review June 29, 2025 13:03
Copy link
Owner

@Devasy Devasy left a comment

Choose a reason for hiding this comment

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

LGTM

@Devasy Devasy merged commit 7b16d09 into main Jun 29, 2025
7 checks passed
@Devasy Devasy deleted the refactor(user)/update-user-service branch June 29, 2025 14:01
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