Skip to content

Organize the tests by component and share one base URL - #55

Merged
chiconws merged 3 commits into
devfrom
simplify/tests-layout
Oct 13, 2026
Merged

chiconws merged 3 commits into
devfrom
simplify/tests-layout

Conversation

@chiconws

Copy link
Copy Markdown
Collaborator

Summary

Test-only cleanup. test_client.py had grown to 44 tests covering every part of the client, and the device URL was written out by hand in most test files. The tests are now grouped by the component they exercise and use one shared URL constant.

Changes

  • test_client.py is split by component. Its tests moved, unchanged, to new files named after the modules in nanokvm/components: test_storage.py, test_network.py, test_system.py, test_stream.py, test_hid.py, test_services.py and test_video.py. Five tests went to files that already covered their subject: version parsing and version gates to test_endpoint_compatibility.py, and payload leaks in errors and logs to test_response_redaction.py.
  • test_client.py keeps the 9 tests about the client itself: the context manager, the response envelope, detect_versions, and one model test that spans two components.
  • One BASE_URL. Tests that spelled out http://localhost:8888/api/ or http://kvm.local/api/, or defined their own _BASE_URL or _URL, now import BASE_URL from tests/common.py. test_ssl.py has a local _BASE_URL because it is the only file that needs HTTPS.
  • AsyncGenerator on async context managers. Two test helpers decorated with @asynccontextmanager were annotated as returning AsyncIterator, which type checkers flag as deprecated.

Notes

  • Some tests that used kvm.local now run against localhost:8888. None of them depended on the host.
  • Two literals stay: the ws:// URL in test_account_permissions.py, used once, and the old-kvm.local and new-kvm.local URLs in test_component_session.py, which test a URL change.
  • Most of the line count in the first commit is ruff-format joining calls that now fit on one line.

Behaviour changes

None. No file under nanokvm/ changes.

Testing

The same 404 unit tests pass after each of the three commits.

@chiconws
chiconws merged commit 65cc25a into dev Oct 13, 2026
2 checks passed
@chiconws
chiconws deleted the simplify/tests-layout branch October 13, 2026 01:19
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