Test/add unit tests and ci - #5
Closed
buckleypaul wants to merge 11 commits into
Closed
Conversation
Add pytest-asyncio to support testing async BLE functions. Signed-off-by: Paul Buckley <paul@hubble.com>
Create tests directory with: - __init__.py package marker - conftest.py with shared pytest fixtures for: - Sample Location, EncryptedPacket, DecryptedPacket - Sample Device and Credentials - Mock fixtures for httpx and bleak Signed-off-by: Paul Buckley <paul@hubble.com>
Test Location, EncryptedPacket, and DecryptedPacket dataclasses: - Instantiation with required and optional fields - Default values - Frozen (immutable) behavior - Equality and hash comparisons Signed-off-by: Paul Buckley <paul@hubble.com>
Test Device dataclass: - Constructor with various arguments - from_json() factory method with complete/partial JSON - ID type conversion (int to string) - Key handling for 128-bit and 256-bit keys - Mutable (non-frozen) behavior Signed-off-by: Paul Buckley <paul@hubble.com>
Test exception classes and helper functions: - Exception inheritance hierarchy validation - map_http_status() for 400, 500, and other status codes - raise_for_response() with dict, string, and None bodies - Error message extraction from various response formats Signed-off-by: Paul Buckley <paul@hubble.com>
Test crypto module functions: - ParsedPacket parsing (sequence, auth tag, payload) - KDF key generation (_generate_kdf_key) - Nonce generation (_get_nonce) - Auth tag generation and verification - Full decrypt() function with valid/invalid keys - find_time_counter_delta() for time sync checking Uses synthetic test vectors by encrypting known payloads. Signed-off-by: Paul Buckley <paul@hubble.com>
Test BLE scanning functions with mocked hardware: - _get_location() returns fake location - Target UUID format validation - scan_async() timeout and packet collection - scan_single_async() first packet detection - Sync/async wrapper functions All tests marked with @pytest.mark.ble for selective running. Signed-off-by: Paul Buckley <paul@hubble.com>
Test cloud module with mocked httpx.Client: - Environment and Credentials dataclasses - cloud_request() with success, errors, timeouts - Continuation token handling for pagination - get_env_from_credentials() validation flow - Device registration, listing, and updates - Packet retrieval and ingestion Signed-off-by: Paul Buckley <paul@hubble.com>
Test Organization class with mocked cloud module: - Constructor with credentials object or explicit args - InvalidCredentialsError when validation fails - Device registration and name updates - Device listing with pagination - Packet retrieval with pagination - Packet ingestion Signed-off-by: Paul Buckley <paul@hubble.com>
Test CLI commands: - Main CLI group help and version options - validate-credentials command - BLE subcommands (detect, scan, check-time) help text - Org subcommands help and credential requirements - Output format options for BLE commands - Environment variable fallback - main() entry point exit codes Note: Due to Click's decorator behavior, org subcommand testing is limited to help text and error handling. Signed-off-by: Paul Buckley <paul@hubble.com>
Configure CI to run on PRs and pushes to main: - Test on Python 3.10, 3.11, and 3.12 - Skip BLE and integration tests (no hardware/credentials) - Generate coverage report with pytest-cov - Upload coverage to Codecov (on Python 3.12) Signed-off-by: Paul Buckley <paul@hubble.com>
buckleypaul
marked this pull request as ready for review
January 21, 2026 01:01
Collaborator
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.