Skip to content

Streamline and isolate the ccu-cli test suite (sussdorff/ccu-cli#7) - #8

Merged
sussdorff merged 3 commits into
mainfrom
chore/7/test-suite-upkeep
Sep 26, 2026
Merged

sussdorff merged 3 commits into
mainfrom
chore/7/test-suite-upkeep

Conversation

@sussdorff

@sussdorff sussdorff commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Streamline and isolate the ccu-cli test suite (#7)

Summary

Brings the suite in line with the test-suite standard (rollout cognovis/library-core#79):

  • An autouse fixture isolates HOME, XDG paths, global Git config and this tool's .env discovery.
  • pytest-xdist runs by default (-n auto).
  • Seven redundant tests are removed and one isolation test is added.
  • The source passes the configured Ruff rules. main already failed Ruff with 92 findings; the fixes are behavior-preserving.

Kept invariants

  • All four --yes guards: confirm, decline and bypass, with assert_not_called() on the destructive call when the user declines.
  • Plain HTTP for ReGa and XML-RPC even when https=True.
  • Latin-1 round trip in both directions, including umlauts in room names.
  • Schedule time boundaries: 00:00, 24:00, single- and two-digit hours, invalid hour 25:00, invalid minute 12:60, missing colon.
  • Every ReGaError "not found" path.
  • CLI error handling is unchanged: the counts of except, sys.exit(1) and click.confirm calls in cli.py match main exactly.

Isolation

load_config() calls load_dotenv(), which searches upward from the package directory and writes to os.environ. A .env beyond the worktree (on this host, ~/.env) could therefore override test values. The fixture now neutralizes load_dotenv and clears the CCU_* variables.

Deleted categories (168 -> 162)

Category Tests
Duplicate at the same seam test_rega.py::test_uses_http_by_default, test_xmlrpc.py::test_uses_http_by_default (stronger siblings assert HTTP under https=True)
Duplicate, weaker test_rega.py::test_returns_response_text, test_handles_multiline_response
Parameter sweep test_schedule.py: test_parses_morning, test_parses_afternoon, test_formats_morning

One test is added, test_environment.py, which asserts that the isolation stays in place.

Ruff repairs

  • 44 except Exception handlers now carry a line-local # noqa: BLE001. There is no rule narrowing, and each suppression is still needed (RUF100 is clean).
  • 17 pass statements after docstrings are removed.
  • 4 nested if not yes: if not confirm(...) blocks become and; short-circuit evaluation keeps the guard.
  • fromtimestamp(ts) becomes fromtimestamp(ts, tz=UTC).astimezone(). The output is identical: 20,000 random timestamps and both DST transitions matched.
  • Annotation-only changes.

Evidence

Run Result Wall
Before, main 168 passed 3.9 s
After, -n0 162 passed 1.0 s
After, parallel (-n auto) 162 passed 2.0 s
After, hostile global Git config 162 passed 2.0 s
  • -n auto is slower than serial here: startup time dominates a sub-second suite. The standard requires parallel by default anyway.
  • uv run ruff check .: all checks passed.
  • uv lock --check: ok. The lock also refreshes a stale self-entry (0.3.1 to 0.4.0).
  • rg -n "uv run" tests: no matches.

Merge Danger

  • Door: two-way.
  • Blast Radius: tests, plus lint-only source edits that keep behavior unchanged.

🤖 Generated with Claude Code


Harness: claude
Session: sc-046d7880ae0712278a08
Beads: #7
Delivered-by: ccore pull-request delivery

Summary by CodeRabbit

  • Bug Fixes
    • Numeric timestamps are now interpreted as UTC before conversion to local time, helping ensure displayed times reflect the correct local time. Handling of string timestamps and zero values remains unchanged. This update applies to timestamps received in numeric form; it does not change how other timestamp formats are displayed.

sussdorff and others added 3 commits September 25, 2026 14:11
load_dotenv() searched upward from the package and wrote os.environ
directly, so a .env outside the worktree changed configuration tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sussdorff sussdorff added the agent/claude Agent-delivered change label Sep 26, 2026
@coderabbitai

coderabbitai Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: sussdorff/ccu-cli/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 206cfd84-815e-49b1-a164-ad910dfbff73

📥 Commits

Reviewing files that changed from the base of the PR and between f5a34c4 and 0cf6d40.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (13)
  • pyproject.toml
  • src/ccu_cli/backend.py
  • src/ccu_cli/cli.py
  • src/ccu_cli/config.py
  • src/ccu_cli/rega.py
  • src/ccu_cli/xmlrpc.py
  • tests/conftest.py
  • tests/test_cli.py
  • tests/test_config.py
  • tests/test_environment.py
  • tests/test_rega.py
  • tests/test_schedule.py
  • tests/test_xmlrpc.py
💤 Files with no reviewable changes (1)
  • src/ccu_cli/config.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The pull request adds test isolation and pytest/Ruff configuration, updates client type annotations and CLI lint handling, changes numeric timestamp conversion, and revises tests for environment isolation and protocol behavior.

Changes

Test setup and isolation

Layer / File(s) Summary
Configure and isolate test runs
pyproject.toml, tests/conftest.py, tests/test_environment.py, tests/test_cli.py, tests/test_config.py
Pytest runs tests from tests with automatic workers, and Ruff excludes .agents and .claude. An autouse fixture isolates home and XDG paths, Git configuration, dotenv loading, and CCU environment variables. An environment test checks these settings; unused imports are removed from two test modules.

Client typing and CLI lint annotations

Layer / File(s) Summary
Update client typing and CLI lint annotations
src/ccu_cli/backend.py, src/ccu_cli/config.py, src/ccu_cli/rega.py, src/ccu_cli/xmlrpc.py, src/ccu_cli/cli.py
Context-manager annotations use Self and object. Redundant exception-class and callback pass statements are removed. CLI broad-exception handlers gain lint-suppression comments; their error handling remains unchanged.

Timestamp and protocol test coverage

Layer / File(s) Summary
Adjust timestamp and protocol test coverage
src/ccu_cli/cli.py, tests/test_rega.py, tests/test_schedule.py, tests/test_xmlrpc.py
Numeric timestamps are interpreted as UTC before local conversion. ReGa tests cover HTTP with HTTPS configured, Latin-1 request and response text, and an unparseable room ID. XML-RPC tests check HTTP with HTTPS configured. Selected schedule tests are removed.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 0cf6d

The changes are mergeable after normal checks; no actionable merge-blocking risk remains identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary changes: streamlining and isolating the ccu-cli test suite.
Docstring Coverage ✅ Passed Docstring coverage is 84.88% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 86 functions across 11 files. (1 skipped: 1…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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.

@sussdorff
sussdorff merged commit 1806844 into main Sep 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent/claude Agent-delivered change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant