v0.1.58 - MockDevice Event Auto-Loading (2025-12-16)¶
What Changed?¶
This release adds automatic event loading to MockDevice from data/events/events.jsonl, enabling testing without hardware. The read command now supports the --mock option, bringing feature parity with the measure command. All changes maintain complete backward compatibility.
What's New¶
Main Feature: MockDevice Auto-Loading Events¶
What it does:
MockDevice now automatically loads detection events from data/events/events.jsonl when initialized. This provides deterministic, reproducible test data without requiring hardware or custom event files. Events are returned sequentially, with priority given to MockGenerator if provided.
How to use it: Simply create a MockDevice instance - events are auto-loaded:
from kazunoko import MockDevice
device = MockDevice() # Auto-loads from data/events/events.jsonl
event = device.receive_response(field_type="event")
print(event.adc) # Access event data
CLI example:
# Test without hardware
kazunoko read 10 --mock
kazunoko measure "1:300;2:300;3:300" 20 --mock
# Time-based collection
kazunoko read 30 --mock --use-duration
Installation¶
Quick Start¶
# Get the release
git checkout vX.Y.Z
# Setup
task env:setup
# Run CLI
uv run kazunoko --help
What's Different from the Last Version?¶
✅ Added¶
_load_events()helper function to load events fromdata/events/events.jsonlMockDevice._get_events()method for sequential event retrieval--mockoption toreadcommand for testing without hardware- Event priority system: MockGenerator > loaded events > command responses
- Comprehensive documentation of event loading behavior in MockDevice docstring
🔧 Changed¶
- MockDevice now auto-loads events from
data/events/events.jsonlon initialization receive_response()updated to implement event priority systemdevice()factory function used consistently in CLI for mock/real device selection- Removed redundant
MockDeviceimports in CLI module
✨ Improved¶
- Clear separation of concerns: MockDevice for testing, MockGenerator for simulation
- Design symmetry:
_get_response()and_get_events()follow same pattern - Better CLI consistency between
readandmeasurecommands
Is It Safe to Upgrade?¶
Backward Compatible: Yes ✅
- All existing APIs unchanged
- MockDevice behavior only enhanced (new event loading), no breaking changes
- Existing code using MockDevice with generator continues to work unchanged
- CLI changes are purely additive (
--mockoption)
Tests Passed¶
- ✅ Builds without errors
- ✅ MockDevice auto-loads 10 events from data/events/events.jsonl
- ✅
kazunoko read 5 --mockreturns 5 events - ✅
kazunoko measure --mockworks with threshold configuration - ✅ MockGenerator priority: generator events > loaded events
- ✅ Event data validation: adc, hit1-3, timestamps correctly populated
- ✅ Code quality: ruff checks pass
Release Details¶
- Date: 2025-12-16
- Version: v0.1.58
- Files Changed: 3
src/kazunoko/mock.py: Event loading implementationsrc/kazunoko/cli.py:--mockoption for read commandCLAUDE.md: Documentation updates- Commits:
5c262b5: feat: add automatic event loading to MockDevicefdbb3ba: feat: add --mock option to read command
Next Steps¶
Potential future enhancements: - Add event reset functionality to MockDevice for repeated test runs - Implement event filtering by event type or field ranges - Support multiple event files with selection by name - Consider performance profiling of event loading for large files