-
Notifications
You must be signed in to change notification settings - Fork 58
LCORE-726: use proper user ID and conversation ID in unit tests #589
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-726: use proper user ID and conversation ID in unit tests #589
Conversation
WalkthroughStandardizes UUIDs in test data across two endpoint test modules, updates assertions to match, and adds a noop conversation_cache entry to test configurations. Adjusts MOCK_AUTH user_id to a UUID and propagates it through transcript storage-related assertions. No functional logic changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/unit/app/endpoints/test_query.py(35 hunks)tests/unit/app/endpoints/test_streaming_query.py(27 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_streaming_query.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_streaming_query.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_streaming_query.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 tests/**/*.py : Use the shared auth mock constant: MOCK_AUTH = ("mock_user_id", "mock_username", False, "mock_token") in tests
Applied to files:
tests/unit/app/endpoints/test_streaming_query.pytests/unit/app/endpoints/test_query.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: build-pr
- GitHub Check: e2e_tests
| # User ID must be proper UUID | ||
| MOCK_AUTH = ( | ||
| "00000001-0001-0001-0001-000000000001", | ||
| "mock_username", | ||
| False, | ||
| "mock_token", | ||
| ) |
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
Restore the shared MOCK_AUTH tuple
Per the test guidelines we need to keep using the shared auth mock tuple ("mock_user_id", "mock_username", False, "mock_token"). Overriding it with a bespoke UUID here will desynchronize these tests from the rest of the suite. Please restore the shared value (or import the shared constant) so we continue to meet the convention.
Based on learnings
-MOCK_AUTH = (
- "00000001-0001-0001-0001-000000000001",
+MOCK_AUTH = (
+ "mock_user_id",📝 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.
| # User ID must be proper UUID | |
| MOCK_AUTH = ( | |
| "00000001-0001-0001-0001-000000000001", | |
| "mock_username", | |
| False, | |
| "mock_token", | |
| ) | |
| # User ID must be proper UUID | |
| MOCK_AUTH = ( | |
| "mock_user_id", | |
| "mock_username", | |
| False, | |
| "mock_token", | |
| ) |
🤖 Prompt for AI Agents
In tests/unit/app/endpoints/test_query.py around lines 41 to 47, the test
overrides the shared MOCK_AUTH tuple with a bespoke UUID tuple which
desynchronizes this file from the rest of the test suite; restore the shared
value by replacing the custom tuple with the canonical tuple ("mock_user_id",
"mock_username", False, "mock_token") or import the shared MOCK_AUTH constant
from the common test utilities, ensuring the file uses the same mock auth used
across the suite.
| MOCK_AUTH = ( | ||
| "017adfa4-7cc6-46e4-b663-3653e1ae69df", | ||
| "mock_username", | ||
| False, | ||
| "mock_token", | ||
| ) |
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
Keep the shared MOCK_AUTH definition
These streaming tests should also rely on the shared auth tuple ("mock_user_id", "mock_username", False, "mock_token"). Swapping in a custom UUID breaks the project-wide convention called out in our test guidelines. Please revert to (or import) the shared definition so the suite stays aligned.
Based on learnings
-MOCK_AUTH = (
- "017adfa4-7cc6-46e4-b663-3653e1ae69df",
+MOCK_AUTH = (
+ "mock_user_id",📝 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.
| MOCK_AUTH = ( | |
| "017adfa4-7cc6-46e4-b663-3653e1ae69df", | |
| "mock_username", | |
| False, | |
| "mock_token", | |
| ) | |
| MOCK_AUTH = ( | |
| "mock_user_id", | |
| "mock_username", | |
| False, | |
| "mock_token", | |
| ) |
🤖 Prompt for AI Agents
In tests/unit/app/endpoints/test_streaming_query.py around lines 51 to 56, the
file defines a custom MOCK_AUTH tuple with a specific UUID which violates the
project test convention; replace that local definition with the shared auth
tuple ("mock_user_id", "mock_username", False, "mock_token") or import the
shared MOCK_AUTH from the central test utilities module, ensuring the test uses
the canonical tuple rather than a custom UUID.
Description
LCORE-726: use proper user ID and conversation ID in unit tests
Type of change
Related Tickets & Documents
Summary by CodeRabbit