Skip to content

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Sep 8, 2025

Description

LCORE-641: authorized response unit tests update

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement

Related Tickets & Documents

  • Related Issue #LCORE-641

Summary by CodeRabbit

  • Tests

    • Updated unit tests to refine authorization response behavior and strengthen field-validation checks.
    • Removed outdated tests for multiple response models to streamline the suite and reduce duplication.
    • Consolidated coverage to improve reliability and clarity of test outcomes.
  • Chores

    • Cleaned up legacy test cases to improve maintainability and speed up test runs.
  • No User-Facing Changes

    • Functionality, APIs, and behavior remain unchanged; this release focuses solely on internal test improvements.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 8, 2025

Walkthrough

Tests were reorganized: a consolidated responses test file was removed, and the AuthorizedResponse tests were updated to set skip_userid_check=True and assert that flag. No production code changes or public API changes were made.

Changes

Cohort / File(s) Summary
AuthorizedResponse tests update
tests/unit/models/responses/test_authorized_response.py
Updated constructor call to set skip_userid_check=True; added assertion verifying ar.skip_userid_check is True; retained existing validation tests.
Remove consolidated responses tests
tests/unit/models/test_responses.py
Deleted file containing unit tests for QueryResponse, StatusResponse, AuthorizedResponse, and UnauthorizedResponse.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I twitch my ears at passing checks,
Hops through tests, no code effects.
One file gone, one truth made tight—
Skip the ID? Set it right.
In burrows neat, assertions cheer,
“Green carrots!” — my favorite gear. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

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

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)
tests/unit/models/responses/test_authorized_response.py (1)

13-22: Parametrize to exercise both True/False and reduce duplication.

Cover both branches in a single test to harden against regressions.

Apply:

-    def test_constructor(self) -> None:
-        """Test the AuthorizedResponse constructor."""
-        ar = AuthorizedResponse(
-            user_id="123e4567-e89b-12d3-a456-426614174000",
-            username="testuser",
-            skip_userid_check=True,
-        )
-        assert ar.user_id == "123e4567-e89b-12d3-a456-426614174000"
-        assert ar.username == "testuser"
-        assert ar.skip_userid_check is True
+    @pytest.mark.parametrize("skip_flag", [True, False])
+    def test_constructor(self, skip_flag: bool) -> None:
+        """Test the AuthorizedResponse constructor."""
+        ar = AuthorizedResponse(
+            user_id="123e4567-e89b-12d3-a456-426614174000",
+            username="testuser",
+            skip_userid_check=skip_flag,
+        )
+        assert ar.user_id == "123e4567-e89b-12d3-a456-426614174000"
+        assert ar.username == "testuser"
+        assert ar.skip_userid_check is skip_flag

Optionally add a separate test to lock the default (if the model’s contract expects False by default):

def test_constructor_default_skip_userid_check_is_false(self) -> None:
    ar = AuthorizedResponse(
        user_id="123e4567-e89b-12d3-a456-426614174000",
        username="testuser",
    )
    assert ar.skip_userid_check is False
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cb70ca1 and 39e0d88.

📒 Files selected for processing (2)
  • tests/unit/models/responses/test_authorized_response.py (1 hunks)
  • tests/unit/models/test_responses.py (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/unit/models/test_responses.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: e2e_tests
  • GitHub Check: build-pr
🔇 Additional comments (3)
tests/unit/models/responses/test_authorized_response.py (3)

18-19: Good: make the intent explicit with skip_userid_check=True.

Passing the flag explicitly decouples the test from model defaults and makes behavior clear.


22-22: Boolean identity check is correct here.

Using “is True” enforces a strict boolean (vs. truthy) check.


13-22: skip_userid_check is a required field with no default
The Pydantic model declares skip_userid_check: bool = Field(...), so it must be provided when constructing AuthorizedResponse and has no default value; the existing test correctly passes this argument.

Likely an incorrect or invalid review comment.

@tisnik tisnik merged commit 16d12e0 into lightspeed-core:main Sep 8, 2025
19 checks passed
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.

1 participant