Skip to content

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Sep 26, 2025

Description

LCORE-726: use proper user ID and conversation ID in unit tests

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-726

Summary by CodeRabbit

  • Tests
    • Standardized test data to use canonical UUIDs for user, conversation, and session identifiers, improving consistency across scenarios.
    • Updated test expectations, mocks, and assertions to align with the new identifier format.
    • Added a no-op conversation cache setting in test configuration to simplify test behavior.
    • Minor tweaks to authentication-related test data to match UUID formatting.
  • Chores
    • No user-facing changes; internal test reliability and maintainability improved.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 26, 2025

Walkthrough

Standardizes 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

Cohort / File(s) Summary
Unit tests: query and streaming endpoints
tests/unit/app/endpoints/test_query.py, tests/unit/app/endpoints/test_streaming_query.py
Replace placeholder IDs with canonical UUIDs in fixtures, mocks, and assertions; add conversation_cache config (type: "noop"); update MOCK_AUTH user_id to a UUID and align dependent assertions; no control-flow changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I thump my paws at tidy IDs, so neat, so true, so clean—
Zeros march in perfect rows, the sleekest I’ve yet seen.
A cache that does a gentle “noop,” no crumbs for me to find,
Yet tests now hum in unison—
A chorus, UUID-aligned. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly summarizes the main change by stating that proper user and conversation IDs are used in unit tests, which aligns directly with the PR objectives and test updates. It is concise, specific, and omits unnecessary details or noise, making it easily understood at a glance.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d10d7c and bfa754b.

📒 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.py
  • tests/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.py
  • tests/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.py
  • tests/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.py
  • tests/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

Comment on lines +41 to +47
# User ID must be proper UUID
MOCK_AUTH = (
"00000001-0001-0001-0001-000000000001",
"mock_username",
False,
"mock_token",
)
Copy link
Contributor

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.

Suggested change
# 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.

Comment on lines +51 to +56
MOCK_AUTH = (
"017adfa4-7cc6-46e4-b663-3653e1ae69df",
"mock_username",
False,
"mock_token",
)
Copy link
Contributor

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.

Suggested change
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.

@tisnik tisnik merged commit 991c001 into lightspeed-core:main Sep 26, 2025
18 of 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