Skip to content

LCORE-1608: more fixes of docstrings in unit tests#1460

Merged
tisnik merged 3 commits into
lightspeed-core:mainfrom
tisnik:lcore-1608-more-fixes-of-docstrings
Apr 6, 2026
Merged

LCORE-1608: more fixes of docstrings in unit tests#1460
tisnik merged 3 commits into
lightspeed-core:mainfrom
tisnik:lcore-1608-more-fixes-of-docstrings

Conversation

@tisnik
Copy link
Copy Markdown
Contributor

@tisnik tisnik commented Apr 6, 2026

Description

LCORE-1608: more fixes of docstrings 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
  • Benchmarks improvement

Tools used to create PR

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

Related Tickets & Documents

  • Related Issue #LCORE-1608

Summary by CodeRabbit

  • Tests
    • Enhanced test documentation and clarity across cache, quota, and observability modules.
    • Updated test docstrings to explicitly specify expected behaviors and outcomes.
    • Marked an incomplete test as skipped to prevent false passes.
    • Added test assertions to verify cache state after operations.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 2026

Walkthrough

All changes are updates to test documentation across multiple test files in the tests/unit/ directory. Test docstrings were expanded to explicitly describe expected behaviors, parameters were clarified, and typographical errors were corrected. One test was marked to skip with a reference to an issue tracker. One additional assertion was added to verify post-deletion state.

Changes

Cohort / File(s) Summary
Cache Tests
tests/unit/cache/test_cache_factory.py, tests/unit/cache/test_noop_cache.py, tests/unit/cache/test_sqlite_cache.py
Expanded docstrings to explicitly describe expected factory/cache behaviors, parameter meanings, and exception types/messages. No logic changes.
Postgres Cache Tests
tests/unit/cache/test_postgres_cache.py
Updated docstrings to clarify expected behaviors; corrected "becuase" to "because"; added pytest.skip() to unimplemented test; added assertion to verify conversation deletion returns zero items on subsequent list operation.
Observability Tests
tests/unit/observability/test_splunk.py
Expanded pytest fixture docstrings to document detailed mock configuration structure and async context manager behavior. No logic changes.
Quota Tests
tests/unit/quota/test_cluster_quota_limiter.py, tests/unit/quota/test_connect_pg.py, tests/unit/quota/test_quota_limiter_factory.py, tests/unit/quota/test_user_quota_limiter.py
Expanded docstrings to explicitly describe expected factory and limiter behaviors; corrected test comments from "cluster" to "user" terminology. No logic changes except docstring updates.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 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 accurately summarizes the main change: docstring fixes in unit tests across multiple test files, with the ticket reference LCORE-1608 providing clear traceability.
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 unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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
Copy Markdown
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: 1

🤖 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/unit/cache/test_sqlite_cache.py`:
- Around line 107-113: The docstring's opening line incorrectly states "DB is
not connected" while the test actually asserts successful initialization and a
non-None connection; update the test docstring for the test in
tests/unit/cache/test_sqlite_cache.py so the first sentence describes that it
verifies creating a SQLiteCache returns a non-None cache and that its connection
attribute on the SQLiteCache instance is not None (i.e., confirms an active DB
connection) and keep the rest of the description about asserting a non-`None`
cache object and `connection` attribute.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 82ca915d-753d-4b69-a491-89a119bc6303

📥 Commits

Reviewing files that changed from the base of the PR and between 7b29914 and 8830f88.

📒 Files selected for processing (9)
  • tests/unit/cache/test_cache_factory.py
  • tests/unit/cache/test_noop_cache.py
  • tests/unit/cache/test_postgres_cache.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/observability/test_splunk.py
  • tests/unit/quota/test_cluster_quota_limiter.py
  • tests/unit/quota/test_connect_pg.py
  • tests/unit/quota/test_quota_limiter_factory.py
  • tests/unit/quota/test_user_quota_limiter.py
📜 Review details
⏰ 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). (5)
  • GitHub Check: build-pr
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
  • GitHub Check: E2E: server mode / ci
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: E2E: library mode / ci
🧰 Additional context used
📓 Path-based instructions (2)
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Use pytest.mark.asyncio marker for async unit tests

Files:

  • tests/unit/cache/test_noop_cache.py
  • tests/unit/cache/test_cache_factory.py
  • tests/unit/quota/test_connect_pg.py
  • tests/unit/quota/test_cluster_quota_limiter.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/quota/test_quota_limiter_factory.py
  • tests/unit/observability/test_splunk.py
  • tests/unit/quota/test_user_quota_limiter.py
  • tests/unit/cache/test_postgres_cache.py
tests/unit/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use pytest-mock for AsyncMock objects in unit tests

Files:

  • tests/unit/cache/test_noop_cache.py
  • tests/unit/cache/test_cache_factory.py
  • tests/unit/quota/test_connect_pg.py
  • tests/unit/quota/test_cluster_quota_limiter.py
  • tests/unit/cache/test_sqlite_cache.py
  • tests/unit/quota/test_quota_limiter_factory.py
  • tests/unit/observability/test_splunk.py
  • tests/unit/quota/test_user_quota_limiter.py
  • tests/unit/cache/test_postgres_cache.py
🔇 Additional comments (15)
tests/unit/observability/test_splunk.py (2)

15-30: LGTM: Excellent docstring improvement!

The expanded docstring clearly documents all mocked Splunk HEC configuration fields and the return value. This significantly improves test maintainability and developer understanding.


47-56: LGTM: Clear and accurate fixture documentation!

The enhanced docstring properly documents the mocker parameter and explains the mock's async context manager structure, making it easy for developers to understand how the fixture behaves.

tests/unit/quota/test_connect_pg.py (2)

14-21: LGTM! Excellent docstring improvement.

The expanded docstring clearly explains the test's purpose, what is being patched, and what is being asserted. This makes the test more self-documenting.


44-52: LGTM! Clear and comprehensive docstring.

The updated docstring effectively documents the error propagation behavior and the expected exception message matching, improving test readability.

tests/unit/quota/test_cluster_quota_limiter.py (2)

19-34: LGTM! Well-documented helper function.

The expanded docstring with detailed parameter descriptions and return type information significantly improves code maintainability and makes the helper's purpose crystal clear.


156-163: LGTM! Comprehensive test documentation.

The expanded docstring clearly specifies the expected exception type and message, making the test's intent and assertions explicit.

tests/unit/quota/test_user_quota_limiter.py (2)

67-67: LGTM! Appropriate terminology correction.

The updates from "cluster" to "user" in these comments correctly reflect that these tests are for UserQuotaLimiter, improving consistency and clarity throughout the test file.

Also applies to: 81-81, 110-110, 132-132, 154-154, 168-168


139-148: LGTM! Clear test documentation.

The expanded docstring explicitly describes the zero-quota scenario and expected QuotaExceedError with user-specific message, making the test's purpose immediately clear.

tests/unit/quota/test_quota_limiter_factory.py (3)

60-67: LGTM! Enhanced test documentation.

The expanded docstring clearly explains the empty-limiters scenario and expected factory behavior, improving test comprehension.


99-108: LGTM! Comprehensive docstring.

The detailed docstring effectively documents the PostgreSQL configuration, mocking strategy, and expected UserQuotaLimiter creation, making the test self-explanatory.


138-145: LGTM! Clear and concise documentation.

The expanded docstring appropriately describes the SQLite in-memory configuration scenario and expected single UserQuotaLimiter instantiation.

tests/unit/cache/test_noop_cache.py (1)

52-59: Docstring clarifications are accurate and consistent with assertions.

These updates improve test intent without changing behavior, and the wording aligns with the actual expectations in each test.

Also applies to: 134-140, 217-224

tests/unit/cache/test_cache_factory.py (1)

132-141: Behavior-focused docstrings look good.

The updated text is clearer and accurately documents expected factory outcomes for valid and invalid configurations.

Also applies to: 149-157, 212-213, 237-238

tests/unit/cache/test_sqlite_cache.py (1)

52-54: The remaining docstring updates are clear and aligned with test intent.

These changes improve readability and expected-behavior documentation without introducing logic drift.

Also applies to: 158-164, 213-220, 309-312, 358-367

tests/unit/cache/test_postgres_cache.py (1)

186-193: Nice test-maintenance updates across docs and expectations.

Clearer behavioral docstrings, explicit pytest.skip rationale, and the added post-delete list() assertion all improve test maintainability.

Also applies to: 275-282, 308-314, 349-357, 368-385, 455-463, 508-514, 600-604

Comment on lines +107 to +113
"""Test the get operation when DB is not connected.

Verify a SQLiteCache can be created and has an active connection.

Asserts that creating a cache in the provided temporary directory returns a
non-`None` cache object and that its `connection` attribute is not `None`.
"""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Docstring opening sentence mismatches test behavior.

Line 107 says “DB is not connected,” but this test asserts a successful initialization with a non-None connection.

Suggested docstring fix
 def test_cache_initialization(tmpdir: Path) -> None:
-    """Test the get operation when DB is not connected.
+    """Test cache initialization when DB is connected.
📝 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
"""Test the get operation when DB is not connected.
Verify a SQLiteCache can be created and has an active connection.
Asserts that creating a cache in the provided temporary directory returns a
non-`None` cache object and that its `connection` attribute is not `None`.
"""
"""Test cache initialization when DB is connected.
Verify a SQLiteCache can be created and has an active connection.
Asserts that creating a cache in the provided temporary directory returns a
non-`None` cache object and that its `connection` attribute is not `None`.
"""
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/unit/cache/test_sqlite_cache.py` around lines 107 - 113, The
docstring's opening line incorrectly states "DB is not connected" while the test
actually asserts successful initialization and a non-None connection; update the
test docstring for the test in tests/unit/cache/test_sqlite_cache.py so the
first sentence describes that it verifies creating a SQLiteCache returns a
non-None cache and that its connection attribute on the SQLiteCache instance is
not None (i.e., confirms an active DB connection) and keep the rest of the
description about asserting a non-`None` cache object and `connection`
attribute.

@tisnik tisnik merged commit 594b455 into lightspeed-core:main Apr 6, 2026
26 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