Skip to content

test: fix docstring/websocket gaps and mirror test layout (#19, #20, #21) - #22

Closed
tschm wants to merge 1 commit into
masterfrom
fix-quality-findings
Closed

tschm wants to merge 1 commit into
masterfrom
fix-quality-findings

Conversation

@tschm

@tschm tschm commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses the three quality-scorecard findings surfaced by the rhiza v1.2.1 update (#18):

#21 details

The layout checker enforces Test<SourceClass> parity in both directions, so the many organizational grouping classes had to be dissolved:

  • Moved all test files into tests/pycharting/<subpkg>/test_<module>.py.
  • Flattened organizational grouping classes (TestHealthCheck, TestValidateInput, …) into module-level test functions.
  • Kept/added the Test<SourceClass> classes the checker requires: TestChartServer, TestDataManager, TestNoCacheStaticFiles, and new TestDataResponse, TestErrorResponse, TestDataValidationError.
  • Merged test_data_slicing.py → test_ingestion.py; folded test_import.py → test_interface.py.
  • Normalized a stray from src.pycharting... import to from pycharting....

Gates

Gate Result
make fmt ✅ PASS
make docs-coverage ✅ 100%
make test ✅ 148 passed, coverage 100%
check_test_layout.py ✅ exits 0

Net: +5 tests (new model/exception tests), same 100% source coverage.

🤖 Generated with Claude Code

)

- #19: add missing docstring to cleanup_globals._reset (docs-coverage 100%)
- #20: guard websocket route introspection against FastAPI _IncludedRouter
- #21: restructure tests/ to mirror src/pycharting/ so check_test_layout.py
  passes — flatten organizational grouping classes into module-level test
  functions, keep/add Test<SourceClass> classes (TestChartServer,
  TestDataManager, TestNoCacheStaticFiles, TestDataResponse, TestErrorResponse,
  TestDataValidationError), merge test_data_slicing into test_ingestion, fold
  test_import into test_interface.

Gates: fmt PASS, docs-coverage 100%, 148 tests PASS (coverage 100%), test-layout OK.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 17, 2026 05:56
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@tschm, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 31 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8d63220f-332c-4761-89e4-9618a623ca80

📥 Commits

Reviewing files that changed from the base of the PR and between dace655 and 29bc1d4.

📒 Files selected for processing (13)
  • tests/pycharting/__init__.py
  • tests/pycharting/api/__init__.py
  • tests/pycharting/api/test_interface.py
  • tests/pycharting/api/test_routes.py
  • tests/pycharting/core/__init__.py
  • tests/pycharting/core/test_lifecycle.py
  • tests/pycharting/core/test_server.py
  • tests/test_api_routes.py
  • tests/test_data_ingestion.py
  • tests/test_data_slicing.py
  • tests/test_import.py
  • tests/test_interface.py
  • tests/test_server.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-quality-findings

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.

from unittest.mock import MagicMock, patch

with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.bind(("", 0))
@tschm

tschm commented Jul 17, 2026

Copy link
Copy Markdown
Owner Author

Superseded by alihaskar#51, which targets the upstream motherrepo (alihaskar/pycharting) instead of the fork. Same commit (29bc1d4).

@tschm tschm closed this Jul 17, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses the rhiza v1.2.1 quality-scorecard findings by (1) restoring full docstring coverage in the test suite, (2) hardening a FastAPI route-introspection test against newer FastAPI/Starlette route objects, and (3) reorganizing the tests/ tree to mirror the src/pycharting/ package layout for test-layout parity checks.

Changes:

  • Reorganized and renamed tests under tests/pycharting/<subpkg>/... to mirror source layout, flattening many grouping classes into module-level test functions.
  • Updated the lifecycle WebSocket-route test to read route.path defensively (via getattr) to tolerate _IncludedRouter entries in app.routes.
  • Added/retained required Test<SourceClass> parity classes and added model-construction tests for DataResponse / ErrorResponse.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/test_server.py Removed legacy location; tests moved under tests/pycharting/core/test_server.py to match mirrored layout.
tests/test_interface.py Removed legacy location; tests moved under tests/pycharting/api/test_interface.py and updated to include missing helper docstring.
tests/test_import.py Removed standalone import smoke tests; folded into tests/pycharting/api/test_interface.py per new layout rules.
tests/test_data_slicing.py Removed legacy location as part of test layout restructuring.
tests/test_data_ingestion.py Removed legacy location as part of test layout restructuring.
tests/test_api_routes.py Removed legacy location; tests moved under tests/pycharting/api/test_routes.py.
tests/pycharting/init.py Added package marker to reflect mirrored test suite layout.
tests/pycharting/api/init.py Added package marker for pycharting.api test subtree.
tests/pycharting/api/test_interface.py New mirrored interface tests (including folded import smoke tests and global cleanup helper docstring).
tests/pycharting/api/test_routes.py New mirrored routes tests and new DataResponse/ErrorResponse model tests.
tests/pycharting/core/init.py Added package marker for pycharting.core test subtree.
tests/pycharting/core/test_server.py New mirrored server tests (moved from legacy location).
tests/pycharting/core/test_lifecycle.py Updated mirrored lifecycle tests (defensive route-path introspection; flattened grouping classes).
Comments suppressed due to low confidence (3)

tests/pycharting/core/test_lifecycle.py:207

  • The broad except Exception will also catch AssertionError, causing genuine failures (e.g. unexpected status code/body) to be reported as skipped tests instead of failing the suite. Split out AssertionError (or narrow the exception type) so assertions still fail and only environment/startup issues are skipped.
    tests/pycharting/core/test_lifecycle.py:232
  • This except Exception will also swallow AssertionError and turn real regressions into skipped tests. Add a separate except AssertionError: raise (or otherwise narrow the caught exceptions) so the test fails when the server responds incorrectly.
    tests/pycharting/core/test_lifecycle.py:159
  • If an assertion fails inside the loop, the server may be left running, leaking threads/ports into subsequent tests. Wrap the loop in a try/finally (or otherwise guarantee cleanup) so stop_server() always runs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tschm
tschm deleted the fix-quality-findings branch July 20, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants