Skip to content

Conversation

@xmican10
Copy link
Contributor

@xmican10 xmican10 commented Oct 30, 2025

… fixtures to conftest.py.

Description

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 #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Tests
    • Added integration fixtures for loading configuration, creating requests, and providing authentication for integration tests.
    • Added integration tests for the config endpoint covering successful responses and missing-configuration errors.
    • Updated info endpoint tests to use a standardized auth type and removed duplicate fixture-based auth utilities.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 30, 2025

Walkthrough

Adds shared integration test fixtures (current_config, test_request, test_auth) in tests/integration/conftest.py and new integration tests for the /config endpoint; updates test_info_integration.py to use the consolidated fixtures and AuthTuple typing.

Changes

Cohort / File(s) Summary
Consolidated fixtures
tests/integration/conftest.py
New fixtures: current_config (loads lightspeed-stack.yaml via configuration.load_configuration), test_request (constructs a minimal FastAPI Request), and async test_auth (awaits NoopAuthDependency with test_request). Added imports for fastapi.Request and authentication.noop.NoopAuthDependency.
Config endpoint integration tests
tests/integration/endpoints/test_config_integration.py
New async tests for /config endpoint: verifies returning configuration when loaded, returning current_config, and raising LogicError when configuration is not loaded. Uses consolidated fixtures.
Info endpoint test adjustments
tests/integration/endpoints/test_info_integration.py
Replaced local test_request/test_auth fixtures with consolidated fixtures; updated test parameter typing to use AuthTuple from authentication.interface. Removed duplicate fixture definitions.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Integration Test
    participant Handler as config_endpoint_handler
    participant Config as configuration module

    Test->>Handler: invoke(auth, request)
    alt configuration loaded
        Handler->>Config: read configuration
        Config-->>Handler: configuration object
        Handler-->>Test: return configuration.configuration
    else configuration missing
        Handler->>Config: read configuration
        Config-->>Handler: returns None / raises
        Handler-->>Test: raise LogicError("configuration is not loaded")
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Mixed additions: new fixtures (including async behavior), new tests, and refactors across multiple test files.
  • Areas to review:
    • Ensure current_config loads the correct file path and yields the expected object shape.
    • Verify test_auth correctly awaits NoopAuthDependency and matches AuthTuple expectations.
    • Confirm test_info_integration.py tests still run with the centralized fixtures and updated type annotations.

Possibly related PRs

Suggested reviewers

  • tisnik

Poem

🐰 In a burrow of tests I gently hop,
Fixtures gathered in one tidy stop.
Configs now shared and checks in sight,
Endpoints tested through day and night,
Hooray — integration hopping on top! 🥕

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 accurately reflects the main changes in the pull request. It correctly identifies two primary objectives: adding integration tests for the /config endpoint and refactoring fixtures (auth and request) to conftest.py. Both changes are confirmed by the raw_summary, which shows new tests in test_config_integration.py and fixture definitions added to conftest.py. The title is specific and clear enough that a teammate reviewing the commit history would understand the core changes. However, there is a spelling error: "fictures" should be "fixtures."
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93de9fe and 1c8f252.

📒 Files selected for processing (3)
  • tests/integration/conftest.py (3 hunks)
  • tests/integration/endpoints/test_config_integration.py (1 hunks)
  • tests/integration/endpoints/test_info_integration.py (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/integration/endpoints/test_config_integration.py
  • tests/integration/conftest.py
🧰 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/integration/endpoints/test_info_integration.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/integration/endpoints/test_info_integration.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/integration/endpoints/test_info_integration.py
🧠 Learnings (3)
📓 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 tests/**/conftest.py : Use conftest.py for shared pytest fixtures
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
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/{unit,integration}/**/*.py : Use pytest for all unit and integration tests
📚 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 : Handle Llama Stack APIConnectionError when interacting with the Llama client

Applied to files:

  • tests/integration/endpoints/test_info_integration.py
📚 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/app/endpoints/**/*.py : In API endpoints, raise FastAPI HTTPException with appropriate status codes for error handling

Applied to files:

  • tests/integration/endpoints/test_info_integration.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). (3)
  • GitHub Check: build-pr
  • GitHub Check: e2e_tests (azure)
  • GitHub Check: e2e_tests (ci)
🔇 Additional comments (2)
tests/integration/endpoints/test_info_integration.py (2)

10-10: Good addition of AuthTuple import for improved type safety.

The import enhances type annotations throughout the test file, replacing generic tuple types with a more specific and meaningful type.


44-44: Type annotation improvements are correct; integration test fixture design is appropriate.

The AuthTuple type annotation adds clarity and improves type safety across the test functions. The test_auth fixture in tests/integration/conftest.py is correctly implemented: it intentionally uses the real NoopAuthDependency for true integration testing (as documented in its docstring), rather than mocking. The MOCK_AUTH constant from the learning applies to unit tests (tests/unit/**/*.py), not integration tests. No changes required.


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/integration/endpoints/test_config_integration.py (1)

61-82: Test logic is correct, but docstring could be more accurate.

The test correctly verifies that LogicError is raised when configuration is not loaded. However, the docstring (line 66) and comment (line 77) incorrectly attribute the failure to "authorization" when it's actually the endpoint handler checking configuration state.

Consider clarifying:

  • Line 66: "Test that endpoint fails when configuration is not loaded"
  • Line 77: "Verify that LogicError is raised when endpoint handler tries to access config"
-    """Test that authorization fails when configuration is not loaded.
+    """Test that endpoint handler fails when configuration is not loaded.
 
     This integration test verifies:
     - LogicError is raised when configuration is not loaded
     - Error message indicates configuration is not loaded
 
     Args:
         test_request: FastAPI request
         test_auth: noop authentication tuple
     """
     
-    # Verify that LogicError is raised when authorization tries to access config
+    # Verify that LogicError is raised when endpoint handler tries to access config
     with pytest.raises(LogicError) as exc_info:
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbb065c and 93de9fe.

📒 Files selected for processing (3)
  • tests/integration/conftest.py (3 hunks)
  • tests/integration/endpoints/test_config_integration.py (1 hunks)
  • tests/integration/endpoints/test_info_integration.py (0 hunks)
💤 Files with no reviewable changes (1)
  • tests/integration/endpoints/test_info_integration.py
🧰 Additional context used
📓 Path-based instructions (4)
**/*.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/integration/endpoints/test_config_integration.py
  • tests/integration/conftest.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/integration/endpoints/test_config_integration.py
  • tests/integration/conftest.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/integration/endpoints/test_config_integration.py
  • tests/integration/conftest.py
tests/**/conftest.py

📄 CodeRabbit inference engine (CLAUDE.md)

Use conftest.py for shared pytest fixtures

Files:

  • tests/integration/conftest.py
🧠 Learnings (2)
📓 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 tests/**/conftest.py : Use conftest.py for shared pytest fixtures
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/{unit,integration}/**/*.py : Use pytest for all unit and integration tests
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/{unit,integration}/**/*.py : Do not use unittest in tests; pytest is the standard
📚 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/**/conftest.py : Use conftest.py for shared pytest fixtures

Applied to files:

  • tests/integration/conftest.py
🧬 Code graph analysis (2)
tests/integration/endpoints/test_config_integration.py (2)
src/configuration.py (2)
  • configuration (73-77)
  • LogicError (35-36)
src/app/endpoints/config.py (1)
  • config_endpoint_handler (63-85)
tests/integration/conftest.py (2)
src/authentication/noop.py (1)
  • NoopAuthDependency (17-42)
src/configuration.py (2)
  • configuration (73-77)
  • load_configuration (56-62)
⏰ 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 (azure)
  • GitHub Check: e2e_tests (ci)
🔇 Additional comments (7)
tests/integration/endpoints/test_config_integration.py (3)

1-9: LGTM: Clean module structure with proper docstring.

The module docstring and imports are well-organized. All imports are used appropriately in the integration tests.


11-33: LGTM: Well-structured integration test with comprehensive documentation.

The test properly verifies the integration between the endpoint handler and configuration system. The docstring clearly explains what is being tested.


36-58: LGTM: Good coverage for root configuration loading.

This test verifies the endpoint works correctly with the root configuration file, complementing the test config verification.

tests/integration/conftest.py (4)

5-6: LGTM: Necessary imports for new fixtures.

The imports support the new test_request and test_auth fixtures added below.


51-67: LGTM: Fixture correctly loads root configuration.

The fixture follows the same pattern as test_config_fixture but loads from the project root. The path construction is correct, and the cleanup is properly handled.


120-128: LGTM: Excellent integration test approach using real authentication.

This fixture correctly uses the actual NoopAuthDependency implementation rather than mocking, making these true integration tests. The fixture properly handles the async nature of the auth dependency and returns the expected authentication tuple.

Based on learnings


108-117: Request scope is sufficient for current usage.

The test_request_fixture uses a minimal scope that works correctly with the codebase. Integration tests successfully use this fixture with the real NoopAuthDependency, which accesses query_params (dependent on query_string ✓). Unit tests throughout the codebase use even more minimal scopes (e.g., {"type": "http"} alone) without issues, indicating Starlette's Request lazily loads fields as needed. The ASGI spec documents theoretical requirements, but Starlette does not enforce all fields at initialization.

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM in overall. Just few nitpicks



@pytest.fixture(name="test_auth")
async def test_auth_fixture(test_request: Request) -> tuple[str, str, bool, str]:
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: the return type is AuthTuple

from authentication.interface import AuthTuple

async def test_config_endpoint_returns_config(
test_config: AppConfig,
test_request: Request,
test_auth: tuple[str, str, bool, str],
Copy link
Contributor

Choose a reason for hiding this comment

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

dtto: AuthTuple (nitpick)

Copy link
Contributor

@radofuchs radofuchs left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM

@tisnik tisnik merged commit 36d0a94 into lightspeed-core:main Oct 30, 2025
18 of 20 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Oct 31, 2025
18 tasks
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