Skip to content

Add unit tests for mycli/packages/special/utils.py#1757

Merged
rolandwalker merged 1 commit intomainfrom
RW/add-special-utils-tests
Mar 31, 2026
Merged

Add unit tests for mycli/packages/special/utils.py#1757
rolandwalker merged 1 commit intomainfrom
RW/add-special-utils-tests

Conversation

@rolandwalker
Copy link
Copy Markdown
Contributor

@rolandwalker rolandwalker commented Mar 30, 2026

Description

Add unit tests for mycli/packages/special/utils.py, migrating existing format_uptime() tests, and adding new tests, in a new file.

The changelog is covered in a general entry in a separate PR.

Motivation: greater test coverage makes the code more amenable to agentic coding.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the AUTHORS file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

@rolandwalker rolandwalker self-assigned this Mar 30, 2026
@github-actions
Copy link
Copy Markdown

  1. Medium - cd success path test can pass even if os.chdir() is never called
    In test_special_utils.py:36, os.chdir is replaced with a no-op lambda and never asserted. Because os.getcwd is also hardcoded, this test would still pass if handle_cd_command() stopped changing directories and only echoed CWD.
    Action: use a MagicMock for os.chdir and assert assert_called_once_with('/tmp/target').

  2. Low - SSL error-path test does not verify cache/retry behavior
    In test_special_utils.py:173, the test checks only one failing call. It does not verify that an OperationalError is not cached and that a subsequent call retries SHOW STATUS LIKE "Ssl_version".
    Action: add a second call after clearing the side effect (or using side_effect sequence) and assert execute call count increments and result can recover.

No direct correctness/security regressions were found in production code in this PR (it only changes tests).

I could not execute the tests locally because uv is not available in this environment (uv: command not found).

migrating existing format_uptime() tests, and adding new tests, in a
new file.
@rolandwalker rolandwalker force-pushed the RW/add-special-utils-tests branch from 5c82a59 to cc3a260 Compare March 30, 2026 21:14
@rolandwalker rolandwalker merged commit 993c863 into main Mar 31, 2026
8 checks passed
@rolandwalker rolandwalker deleted the RW/add-special-utils-tests branch March 31, 2026 10:13
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.

2 participants