Skip to content

LCORE-657: Unit tests for configuration#1139

Merged
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-657-unit-tests-for-configuration
Feb 12, 2026
Merged

LCORE-657: Unit tests for configuration#1139
tisnik merged 1 commit intolightspeed-core:mainfrom
tisnik:lcore-657-unit-tests-for-configuration

Conversation

@tisnik
Copy link
Contributor

@tisnik tisnik commented Feb 12, 2026

Description

LCORE-657: Unit tests for configuration

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

Summary by CodeRabbit

  • Tests
    • Expanded configuration test coverage for uninitialized-access behavior across more public properties (a2a_state, token usage history, azure_entra_id, splunk, deployment environment).
    • Added initialization and YAML-loading tests covering new public subsections (a2a_state variations, splunk settings, deployment_environment) and token history enablement scenarios — including token history enabled without storage.
    • Ensured defaults (e.g., token_usage_history) and presence assertions are validated.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

Adds and expands unit tests for AppConfig to cover additional public configuration subsections: a2a_state, token_usage_history, azure_entra_id, splunk, and deployment_environment; updates test YAML and init data to assert presence and defaults for these sections.

Changes

Cohort / File(s) Summary
Test updates
tests/unit/test_configuration.py
Replaces generic exception expectations with LogicError for uninitialized config access; adds tests for a2a_state, token_usage_history, azure_entra_id, splunk, and deployment_environment; extends init_from_dict/YAML load test data to include these subsections and cases with token history enabled or enabled-without-storage.
Notes
(no production files changed)
No changes to public API signatures or production code — modifications are confined to test code and test data setup.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 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 unit tests for configuration as part of ticket LCORE-657.
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
🧪 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: 1

🤖 Fix all issues with AI agents
In `@tests/unit/test_configuration.py`:
- Around line 96-114: Update the five raises in tests/unit/test_configuration.py
to assert the specific LogicError instead of the broad Exception: replace
pytest.raises(Exception, match="logic error: configuration is not loaded") with
pytest.raises(LogicError, match="logic error: configuration is not loaded") for
the checks that access cfg.a2a_state, cfg.token_usage_history,
cfg.azure_entra_id, cfg.splunk, and cfg.deployment_environment; also ensure
LogicError is imported into the test module (or referenced from its defining
module) so the test file references the correct exception class.

@tisnik tisnik force-pushed the lcore-657-unit-tests-for-configuration branch from d6ed09e to ce7dc89 Compare February 12, 2026 07:49
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

🤖 Fix all issues with AI agents
In `@tests/unit/test_configuration.py`:
- Around line 222-223: The test currently only checks cfg.deployment_environment
is not None; change it to assert the concrete expected value by replacing that
check with an equality assertion (e.g., assert cfg.deployment_environment ==
"foo") so the test verifies the value set earlier in the fixture; locate the
assertion referencing cfg.deployment_environment in the test_configuration.py
test block and update it accordingly.
- Around line 780-781: The docstring for
test_configuration_with_token_history_no_storage is incorrect (it references
"quota handlers configuration"); update the function's docstring to accurately
describe that the test verifies loading configuration from YAML for token
history settings when no storage backend is configured, e.g., mention "token
history when no storage backend is configured" and keep it concise to match the
test purpose.

Comment on lines +222 to +223
# check deployment_environment
assert cfg.deployment_environment is not None
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Assert the actual value of deployment_environment, not just non-None.

The dict on line 161 sets "deployment_environment": "foo", but the assertion here only checks is not None. Every other field in this test block asserts the concrete value. This should do the same to avoid silently passing when the value is wrong.

Proposed fix
     # check deployment_environment
-    assert cfg.deployment_environment is not None
+    assert cfg.deployment_environment == "foo"
📝 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
# check deployment_environment
assert cfg.deployment_environment is not None
# check deployment_environment
assert cfg.deployment_environment == "foo"
🤖 Prompt for AI Agents
In `@tests/unit/test_configuration.py` around lines 222 - 223, The test currently
only checks cfg.deployment_environment is not None; change it to assert the
concrete expected value by replacing that check with an equality assertion
(e.g., assert cfg.deployment_environment == "foo") so the test verifies the
value set earlier in the fixture; locate the assertion referencing
cfg.deployment_environment in the test_configuration.py test block and update it
accordingly.

Comment on lines +780 to +781
def test_configuration_with_token_history_no_storage(tmpdir: Path) -> None:
"""Test loading configuration from YAML file with quota handlers configuration."""
Copy link
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 is a copy-paste from test_configuration_with_quota_handlers_no_storage.

The docstring says "quota handlers configuration" but the test is specifically about token history when no storage backend is configured.

Proposed fix
 def test_configuration_with_token_history_no_storage(tmpdir: Path) -> None:
-    """Test loading configuration from YAML file with quota handlers configuration."""
+    """Test token usage history is created when enabled without storage backend."""
📝 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
def test_configuration_with_token_history_no_storage(tmpdir: Path) -> None:
"""Test loading configuration from YAML file with quota handlers configuration."""
def test_configuration_with_token_history_no_storage(tmpdir: Path) -> None:
"""Test token usage history is created when enabled without storage backend."""
🤖 Prompt for AI Agents
In `@tests/unit/test_configuration.py` around lines 780 - 781, The docstring for
test_configuration_with_token_history_no_storage is incorrect (it references
"quota handlers configuration"); update the function's docstring to accurately
describe that the test verifies loading configuration from YAML for token
history settings when no storage backend is configured, e.g., mention "token
history when no storage backend is configured" and keep it concise to match the
test purpose.

@tisnik tisnik merged commit 1d4c3a5 into lightspeed-core:main Feb 12, 2026
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