-
Notifications
You must be signed in to change notification settings - Fork 52
LCORE-740: Added type hints into unit tests for checking endpoint handlers #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LCORE-740: Added type hints into unit tests for checking endpoint handlers #726
Conversation
WalkthroughAdded explicit type annotations (parameter and return types), introduced Changes
Sequence Diagram(s)(No sequence diagram — changes are typing-only and do not alter runtime control flow.) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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 (5)
tests/unit/app/endpoints/test_config.py (5)
18-18: Make the docstring more descriptive.The docstring should describe the specific test scenario being validated. Consider: "Test the config endpoint handler when configuration is not loaded."
As per coding guidelines.
Apply this diff:
- """Test the config endpoint handler.""" + """Test the config endpoint handler when configuration is not loaded."""
35-35: Use the shared MOCK_AUTH constant instead of creating a custom auth tuple.The coding guidelines specify using the shared auth mock constant:
MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token")in tests.As per coding guidelines.
Apply this diff to import and use the constant:
+from tests.unit.utils.auth_helpers import MOCK_AUTHThen update the auth assignment:
- # authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") + # authorization tuple required by URL endpoint handler + auth: AuthTuple = MOCK_AUTH
49-49: Make the docstring more descriptive and unique.The docstring is identical to the first test but should describe the specific test scenario. Consider: "Test the config endpoint handler when configuration is loaded."
As per coding guidelines.
Apply this diff:
- """Test the config endpoint handler.""" + """Test the config endpoint handler when configuration is loaded."""
52-52: Consider using more precise type hints for the config dictionary.The
dict[Any, Any]type annotation is imprecise. Consider using a TypedDict or more specific types for the configuration structure.Based on learnings.
For example:
config_dict: dict[str, Any] = { # ... configuration keys are strings }
90-90: Use the shared MOCK_AUTH constant instead of creating a custom auth tuple.The coding guidelines specify using the shared auth mock constant:
MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token")in tests.As per coding guidelines.
Apply this diff to import and use the constant:
+from tests.unit.utils.auth_helpers import MOCK_AUTHThen update the auth assignment:
- # authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") + # authorization tuple required by URL endpoint handler + auth: AuthTuple = MOCK_AUTH
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/unit/app/endpoints/test_config.py(3 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed
Files:
tests/unit/app/endpoints/test_config.py
tests/{unit,integration}/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest in tests; pytest is the standard
Files:
tests/unit/app/endpoints/test_config.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.py: Use pytest-mock to create AsyncMock objects for async interactions in tests
Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests
Files:
tests/unit/app/endpoints/test_config.py
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to src/{models/**/*.py,configuration.py} : Use precise type hints in configuration (e.g., Optional[FilePath], PositiveInt, SecretStr)
🧬 Code graph analysis (1)
tests/unit/app/endpoints/test_config.py (3)
src/app/endpoints/config.py (1)
config_endpoint_handler(63-85)src/configuration.py (2)
configuration(73-77)AppConfig(39-181)tests/unit/utils/auth_helpers.py (1)
mock_authorization_resolvers(8-26)
⏰ 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). (3)
- GitHub Check: build-pr
- GitHub Check: e2e_tests (ci)
- GitHub Check: e2e_tests (azure)
🔇 Additional comments (2)
tests/unit/app/endpoints/test_config.py (2)
3-3: LGTM! Import additions support the type annotations.The new imports are necessary and appropriate for the type hints added to the test functions.
Also applies to: 8-8
42-42: The review comment is incorrect; no legitimate type issue exists.The
# type: ignoresuppression is not masking a bug. The code intentionally passesdetailas a dictionary insrc/utils/endpoints.py:120-122:raise HTTPException( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, detail={"response": "Configuration is not loaded"}, )The test correctly accesses
detail["response"]. This pattern appears throughout the test suite (test_models.py, test_shields.py, test_query.py, test_conversations.py, test_streaming_query.py) and many of these identical accesses work without the# type: ignorecomment. The suppression addresses a known Starlette type annotation limitation wheredetailis typed asstrbut accepts any JSON-serializable value—not a code correctness issue.Likely an incorrect or invalid review comment.
6d05d3a to
a392d03
Compare
There was a problem hiding this 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 (2)
tests/unit/app/endpoints/test_feedback.py (2)
79-81: Type annotations correctly applied to parametrized tests.The parameter and return type annotations are properly added. The use of
dict[Any, Any]for feedback payload parameters is safe and flexible.Consider using
dict[str, Any]instead ofdict[Any, Any]for slightly more precise typing, since feedback payloads typically have string keys:- mocker: MockerFixture, feedback_request_data: dict[Any, Any] + mocker: MockerFixture, feedback_request_data: dict[str, Any]This would apply to the parameters in lines 80, 159, 207, and 274.
Also applies to: 158-160, 206-208, 273-275
94-96: LGTM! Auth tuple type annotations correctly applied.The local
auth: AuthTuplevariables are properly typed and intentionally use"test_user_id"to match the assertions in the respective tests (e.g., lines 238, 258). This differs appropriately from theMOCK_AUTHconstant used in other tests.The comments "Authorization tuple required by URL endpoint handler" are somewhat redundant given the explicit
auth: AuthTupletype annotation. Consider removing them for brevity:- # Authorization tuple required by URL endpoint handler auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") -Also applies to: 123-125, 227-229, 247-249
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
tests/unit/app/endpoints/test_feedback.py(12 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed
Files:
tests/unit/app/endpoints/test_feedback.py
tests/{unit,integration}/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest in tests; pytest is the standard
Files:
tests/unit/app/endpoints/test_feedback.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.py: Use pytest-mock to create AsyncMock objects for async interactions in tests
Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests
Files:
tests/unit/app/endpoints/test_feedback.py
🧬 Code graph analysis (1)
tests/unit/app/endpoints/test_feedback.py (3)
src/configuration.py (2)
configuration(73-77)user_data_collection_configuration(94-98)src/app/endpoints/feedback.py (4)
is_feedback_enabled(79-89)feedback_endpoint_handler(114-152)assert_feedback_enabled(92-109)update_feedback_status(210-246)src/models/requests.py (1)
FeedbackStatusUpdateRequest(390-415)
⏰ 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). (3)
- GitHub Check: build-pr
- GitHub Check: e2e_tests (azure)
- GitHub Check: e2e_tests (ci)
🔇 Additional comments (4)
tests/unit/app/endpoints/test_feedback.py (4)
3-3: LGTM! Necessary imports for type hints.The additions of
AnyandAuthTupleimports appropriately support the type annotations introduced throughout the test file.Also applies to: 16-16
29-29: LGTM! Return type annotations correctly applied.The
-> Nonereturn type annotations andMockerFixtureparameter types are correctly applied and follow the coding guidelines for complete type annotations.Also applies to: 35-35, 41-41, 54-54, 109-109
135-135: LGTM! Appropriate use of type: ignore.The
# type: ignorecomment is correctly applied here. The endpoint handler raisesHTTPExceptionwith a dictionarydetail(as seen in the handler implementation), but the type checker may expectdetailto be a string. This is a legitimate suppression of a false positive.
223-223: LGTM! Type annotations properly added to feedback status update tests.The addition of
mocker: MockerFixtureparameter typing and-> Nonereturn annotations completes the type hint coverage for these test functions. Themockerparameter is appropriately used withmocker.ANYin the test assertions.Also applies to: 243-243
f87fb34 to
fcb8b0f
Compare
There was a problem hiding this 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 (4)
tests/unit/app/endpoints/test_feedback.py (4)
79-81: Good type annotations, but consider using the existing MOCK_AUTH constant.The type annotations are correct and improve type safety. However, this test creates a custom auth tuple instead of using the
MOCK_AUTHconstant defined at line 21. For consistency and maintainability, consider reusing the shared constant. As per coding guidelines, using the shared auth mock constant is recommended.Apply this diff to use the shared constant:
- # Authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") - # Call the endpoint handler result = await feedback_endpoint_handler( feedback_request=feedback_request, _ensure_feedback_enabled=assert_feedback_enabled, - auth=auth, + auth=MOCK_AUTH, )Based on coding guidelines.
Also applies to: 94-96, 101-101
109-109: Type annotations look good, consider MOCK_AUTH for consistency.Similar to the previous test, the type annotations are correct but creating a custom auth tuple instead of using
MOCK_AUTHreduces consistency across the test suite.Consider using the shared
MOCK_AUTHconstant for consistency:- # Authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") - # Call the endpoint handler and assert it raises an exception with pytest.raises(HTTPException) as exc_info: await feedback_endpoint_handler( feedback_request=feedback_request, _ensure_feedback_enabled=assert_feedback_enabled, - auth=auth, + auth=MOCK_AUTH, )Based on coding guidelines.
Also applies to: 123-125, 131-131
223-229: Type annotations are correct, but auth tuple usage is inconsistent.The type annotations properly document the function signatures. However, these tests create custom auth tuples while
test_feedback_endpoint_valid_requests(line 282) uses the sharedMOCK_AUTHconstant. For consistency and maintainability, consider usingMOCK_AUTHthroughout the file.Consider standardizing on
MOCK_AUTH:- # Authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") - req = FeedbackStatusUpdateRequest(status=False) resp = await update_feedback_status( req, - auth=auth, + auth=MOCK_AUTH, )And similarly for
test_update_feedback_status_no_change. Based on coding guidelines.Also applies to: 233-233, 243-249, 253-253
135-135: Consider a more specific type: ignore comment.The broad
# type: ignorecomment suppresses all type checking for this line. Consider using a more specific suppression like# type: ignore[index]or restructuring to make the type explicit.For example:
- assert exc_info.value.detail["response"] == "Error storing user feedback" # type: ignore + detail = exc_info.value.detail + assert isinstance(detail, dict) + assert detail["response"] == "Error storing user feedback"Or use a more specific ignore:
- assert exc_info.value.detail["response"] == "Error storing user feedback" # type: ignore + assert exc_info.value.detail["response"] == "Error storing user feedback" # type: ignore[index]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/unit/app/endpoints/test_feedback.py(12 hunks)tests/unit/app/endpoints/test_health.py(10 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed
Files:
tests/unit/app/endpoints/test_health.pytests/unit/app/endpoints/test_feedback.py
tests/{unit,integration}/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest in tests; pytest is the standard
Files:
tests/unit/app/endpoints/test_health.pytests/unit/app/endpoints/test_feedback.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.py: Use pytest-mock to create AsyncMock objects for async interactions in tests
Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests
Files:
tests/unit/app/endpoints/test_health.pytests/unit/app/endpoints/test_feedback.py
🧬 Code graph analysis (2)
tests/unit/app/endpoints/test_health.py (1)
tests/unit/utils/auth_helpers.py (1)
mock_authorization_resolvers(8-26)
tests/unit/app/endpoints/test_feedback.py (1)
src/app/endpoints/feedback.py (4)
is_feedback_enabled(79-89)feedback_endpoint_handler(114-152)assert_feedback_enabled(92-109)update_feedback_status(210-246)
⏰ 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). (3)
- GitHub Check: build-pr
- GitHub Check: e2e_tests (ci)
- GitHub Check: e2e_tests (azure)
🔇 Additional comments (5)
tests/unit/app/endpoints/test_health.py (3)
7-7: LGTM! Excellent type annotation work.The import of
AuthTupleand its usage with explicit type annotations improves type safety and code clarity. The inline comment explaining the auth tuple is helpful.Also applies to: 18-20, 38-40
53-53: LGTM! Consistent typing pattern.The return type annotations and
AuthTupleusage maintain consistency across all test functions. The pattern is clean and well-documented.Also applies to: 76-78, 90-96
105-105: LGTM! Complete type coverage.All test methods now have proper return type annotations, completing the type coverage for this test module.
Also applies to: 114-114, 125-125, 176-178
tests/unit/app/endpoints/test_feedback.py (2)
3-3: LGTM! Good foundation with type imports.The addition of
AnyandAuthTupleimports along with return type annotations establishes proper type coverage for the test module.Also applies to: 16-16, 29-29, 35-35, 41-41, 54-54
158-160: LGTM! Clean parameter type annotations.The use of
dict[str, Any]for the feedback request data parameter is correct and follows modern Python typing conventions.Also applies to: 206-208
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
f2aa278 to
a9297d7
Compare
a9297d7 to
27f3f92
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai fullreview |
|
@tisnik: I'll perform a full review of all the changes in this PR. ✅ Actions performedFull review triggered. |
|
@coderabbitai fullreview |
|
@tisnik: I'll perform a full review of all the changes in this PR. ✅ Actions performedFull review triggered. |
There was a problem hiding this 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 (4)
tests/unit/app/endpoints/test_info.py (1)
69-69: Consider using the shared MOCK_AUTH constant.Both test functions construct identical auth tuples inline. As per coding guidelines, tests should use the shared auth mock constant. Consider defining a module-level constant or using a shared constant from a test utilities module to reduce duplication and improve maintainability.
Based on coding guidelines.
Apply this diff to use a shared constant:
+# Shared auth constant for tests +MOCK_AUTH: AuthTuple = ("test_user_id", "test_user", True, "test_token") + @pytest.mark.asyncio async def test_info_endpoint(mocker: MockerFixture) -> None: """Test the info endpoint handler.""" ... - # Authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") + # Authorization tuple required by URL endpoint handler + auth: AuthTuple = MOCK_AUTHThen apply the same pattern to line 130.
Also applies to: 130-130
tests/unit/app/endpoints/test_config.py (1)
36-36: Consider using the shared MOCK_AUTH constant.Both test functions construct identical auth tuples inline. As per coding guidelines, tests should use a shared auth mock constant to reduce duplication.
Based on coding guidelines.
Consider defining a module-level constant:
+# Shared auth constant for tests +MOCK_AUTH: AuthTuple = ("test_user_id", "test_user", True, "test_token") + @pytest.mark.asyncio async def test_config_endpoint_handler_configuration_not_loaded( mocker: MockerFixture, ) -> None: ... - # authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") + # authorization tuple required by URL endpoint handler + auth: AuthTuple = MOCK_AUTHAlso applies to: 97-97
tests/unit/app/endpoints/test_health.py (1)
40-40: Consider using the shared MOCK_AUTH constant.Multiple test functions construct identical auth tuples inline. As per coding guidelines, tests should use a shared auth mock constant to reduce duplication and improve consistency.
Based on coding guidelines.
Consider defining a module-level constant:
+# Shared auth constant for tests +MOCK_AUTH: AuthTuple = ("test_user_id", "test_user", True, "test_token")Then replace the inline constructions with references to this constant.
Also applies to: 78-78, 95-95
tests/unit/app/endpoints/test_feedback.py (1)
95-95: Inconsistent auth tuple usage.This file defines a module-level
MOCK_AUTHconstant at line 21, and one test (test_feedback_endpoint_valid_requestsat line 285) correctly uses it. However, several other tests construct inline auth tuples with different values ("test_user_id" vs "mock_user_id").For consistency and maintainability, consider using the module-level
MOCK_AUTHconstant across all tests unless there's a specific requirement for different auth values.Based on coding guidelines.
- # Authorization tuple required by URL endpoint handler - auth: AuthTuple = ("test_user_id", "test_user", True, "test_token") + # Authorization tuple required by URL endpoint handler + auth: AuthTuple = MOCK_AUTHAlso applies to: 124-124, 231-231, 251-251
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
tests/unit/app/endpoints/test_config.py(2 hunks)tests/unit/app/endpoints/test_feedback.py(12 hunks)tests/unit/app/endpoints/test_health.py(10 hunks)tests/unit/app/endpoints/test_info.py(5 hunks)tests/unit/app/endpoints/test_query.py(50 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.py: All modules start with descriptive module-level docstrings explaining purpose
Use logger = logging.getLogger(name) for module logging after import logging
Define type aliases at module level for clarity
All functions require docstrings with brief descriptions
Provide complete type annotations for all function parameters and return types
Use typing_extensions.Self in model validators where appropriate
Use modern union syntax (str | int) and Optional[T] or T | None consistently
Function names use snake_case with descriptive, action-oriented prefixes (get_, validate_, check_)
Avoid in-place parameter modification; return new data structures instead of mutating arguments
Use appropriate logging levels: debug, info, warning, error with clear messages
All classes require descriptive docstrings explaining purpose
Class names use PascalCase with conventional suffixes (Configuration, Error/Exception, Resolver, Interface)
Abstract base classes should use abc.ABC and @AbstractMethod for interfaces
Provide complete type annotations for all class attributes
Follow Google Python docstring style for modules, classes, and functions, including Args, Returns, Raises, Attributes sections as needed
Files:
tests/unit/app/endpoints/test_health.pytests/unit/app/endpoints/test_feedback.pytests/unit/app/endpoints/test_info.pytests/unit/app/endpoints/test_config.pytests/unit/app/endpoints/test_query.py
tests/{unit,integration}/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/{unit,integration}/**/*.py: Use pytest for all unit and integration tests
Do not use unittest in tests; pytest is the standard
Files:
tests/unit/app/endpoints/test_health.pytests/unit/app/endpoints/test_feedback.pytests/unit/app/endpoints/test_info.pytests/unit/app/endpoints/test_config.pytests/unit/app/endpoints/test_query.py
tests/**/*.py
📄 CodeRabbit inference engine (CLAUDE.md)
tests/**/*.py: Use pytest-mock to create AsyncMock objects for async interactions in tests
Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests
Files:
tests/unit/app/endpoints/test_health.pytests/unit/app/endpoints/test_feedback.pytests/unit/app/endpoints/test_info.pytests/unit/app/endpoints/test_config.pytests/unit/app/endpoints/test_query.py
🧠 Learnings (1)
📚 Learning: 2025-09-18T16:46:33.353Z
Learnt from: CR
PR: lightspeed-core/lightspeed-stack#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-18T16:46:33.353Z
Learning: Applies to src/client.py : Use Llama Stack client import: from llama_stack_client import AsyncLlamaStackClient
Applied to files:
tests/unit/app/endpoints/test_info.py
| def __init__(self, identifier: str): | ||
| self.identifier = identifier |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion | 🟠 Major
Add missing return type annotation.
The __init__ method in the MockShield class at line 758 is missing a return type annotation. Other similar MockShield classes in this file (lines 702 and 817) correctly include -> None on their __init__ methods.
Based on coding guidelines.
Apply this diff:
- def __init__(self, identifier: str):
+ def __init__(self, identifier: str) -> None:
self.identifier = identifier🤖 Prompt for AI Agents
In tests/unit/app/endpoints/test_query.py around lines 758-759, the
MockShield.__init__ method is missing a return type annotation; update its
signature to include "-> None" (making it def __init__(self, identifier: str) ->
None:) to match the other MockShield classes in the file and adhere to the
project's typing guidelines.
Description
LCORE-740: Added type hints into unit tests for checking endpoint handlers:
/configendpoint/feedbackendpoint/healthendpointType of change
Related Tickets & Documents
Summary by CodeRabbit