Skip to content

Comments

LCORE-1360: Integration tests for /root endpoint#1194

Merged
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-1360-integration-tests-for-root-endpoint
Feb 22, 2026
Merged

LCORE-1360: Integration tests for /root endpoint#1194
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-1360-integration-tests-for-root-endpoint

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Feb 22, 2026

Description

LCORE-1360: Integration tests for /root endpoint

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
  • Benchmarks improvement

Tools used to create PR

  • Assisted-by: N/A
  • Generated by: N/A

Related Tickets & Documents

  • Related Issue #LCORE-1360

Summary by CodeRabbit

  • Tests
    • Added integration tests for the root endpoint that verify correct HTTP response formatting and behavior. Tests include mocking an external service client, validating HTTP 200 status and media type "text/html", and checking that the returned HTML contains the expected page title and header content. These tests help ensure stable endpoint responses and HTML structure.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 22, 2026

No actionable comments were generated in the recent review. 🎉


Walkthrough

Adds a new integration test for the /root endpoint that mocks the AsyncLlamaStackClientHolder, configures a mocked version response, and verifies the handler returns an HTML response with HTTP 200 and expected title/header.

Changes

Cohort / File(s) Summary
Root Endpoint Integration Tests
tests/integration/endpoints/test_root_endpoint.py
New integration test for the /root endpoint. Mocks AsyncLlamaStackClientHolder, sets inspect.version to VersionInfo(version="0.2.22"), invokes root_endpoint_handler, and asserts media type text/html, status 200, and presence of <title> and <h1> content.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 3
✅ 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 and specifically describes the main change: adding integration tests for the /root endpoint, which matches the changeset content exactly.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • 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

🧹 Nitpick comments (1)
tests/integration/endpoints/test_root_endpoint.py (1)

15-40: Remove the unused mock_llama_stack_client fixture — it's dead code that patches the wrong module.

Two problems here:

  1. The patch target is "app.endpoints.info.AsyncLlamaStackClientHolder", which belongs to the info endpoint module, not the root endpoint. This is almost certainly a copy-paste from test_info_endpoint.py.
  2. The fixture is never injected into test_root_endpoint (it's not listed as a parameter), so the patch is never applied when the test runs.

Looking at the relevant snippet of root_endpoint_handler in src/app/endpoints/root.py (lines 788–807), the handler makes no external service calls — it simply returns HTMLResponse(INDEX_PAGE). The fixture is therefore entirely unnecessary for this test file and should be removed along with its now-orphaned VersionInfo import.

♻️ Proposed cleanup
-from typing import Generator, Any
+from typing import Any
 import pytest
 from pytest_mock import MockerFixture

 from fastapi import Request, status
-from llama_stack_client.types import VersionInfo
 from authentication.interface import AuthTuple
 
 from configuration import AppConfig
 from app.endpoints.root import root_endpoint_handler
-
-
-@pytest.fixture(name="mock_llama_stack_client")
-def mock_llama_stack_client_fixture(
-    mocker: MockerFixture,
-) -> Generator[Any, None, None]:
-    """Mock only the external Llama Stack client.
-    ...
-    """
-    mock_holder_class = mocker.patch("app.endpoints.info.AsyncLlamaStackClientHolder")
-
-    mock_client = mocker.AsyncMock()
-    mock_client.inspect.version.return_value = VersionInfo(version="0.2.22")
-
-    mock_holder_instance = mock_holder_class.return_value
-    mock_holder_instance.get_client.return_value = mock_client
-
-    yield mock_client
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/integration/endpoints/test_root_endpoint.py` around lines 15 - 40,
Remove the dead fixture mock_llama_stack_client and the unused VersionInfo
import from the test file: delete the pytest fixture named
mock_llama_stack_client (which patches AsyncLlamaStackClientHolder) and any
references to VersionInfo, since root_endpoint_handler simply returns
HTMLResponse(INDEX_PAGE) and the fixture is never injected into tests; this
eliminates the incorrect patch target
("app.endpoints.info.AsyncLlamaStackClientHolder") and unused code in
tests/integration/endpoints/test_root_endpoint.py.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/integration/endpoints/test_root_endpoint.py`:
- Around line 68-70: Replace the incorrect bytes-to-string conversion using
str(response.body) with an explicit UTF-8 decode: change the assignment that
sets body (from response.body) to call response.body.decode("utf-8") so the test
works with the actual decoded HTML string; update the assertions that reference
body (the two checks for "<title>Lightspeed core service</title>" and
"<h1>Lightspeed core service</h1>") to use this decoded value.
- Around line 56-59: Update the stale docstring parameter name: replace the
documented parameter "current_config (AppConfig)" with the actual parameter name
"test_config (AppConfig)" in the test_root_endpoint.py docstring so the
Parameters section matches the function signature and the other documented
params (test_request, test_auth); locate the docstring that lists Parameters and
adjust the identifier only (leave the type and description unchanged).

---

Nitpick comments:
In `@tests/integration/endpoints/test_root_endpoint.py`:
- Around line 15-40: Remove the dead fixture mock_llama_stack_client and the
unused VersionInfo import from the test file: delete the pytest fixture named
mock_llama_stack_client (which patches AsyncLlamaStackClientHolder) and any
references to VersionInfo, since root_endpoint_handler simply returns
HTMLResponse(INDEX_PAGE) and the fixture is never injected into tests; this
eliminates the incorrect patch target
("app.endpoints.info.AsyncLlamaStackClientHolder") and unused code in
tests/integration/endpoints/test_root_endpoint.py.

@tisnik tisnik force-pushed the lcore-1360-integration-tests-for-root-endpoint branch from 3cb88dc to e0bcf35 Compare February 22, 2026 13:49
@tisnik tisnik merged commit 6c1821d into lightspeed-core:main Feb 22, 2026
20 of 22 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