Skip to content

v0.1.1 - Testing Support with MockDevice (2025-12-01)

What Changed?

This release adds comprehensive testing support through MockDevice, enabling developers to test CLI and library functionality without physical hardware. The codebase has been refactored with a DeviceProtocol interface to support multiple device implementations. All responses now properly distinguish between real device, data events, and mock responses.


What's New

Main Feature: MockDevice for Testing

What it does: MockDevice simulates an OSECHI detector in software, supporting all standard commands (STATUS, GET_VERSION, SET_POLL_COUNT, etc.) and maintaining internal state just like a real device. Perfect for testing and CI/CD pipelines without hardware.

How to use it:

# Test status command with mock device
kazunoko info --mock

# Test detection event listening with 3 events
kazunoko listen --mock --count 3

# Send any command to mock device
kazunoko send "SET_POLL_COUNT 200" --mock

Code example(if relevant):

from kazunoko import MockDevice

# Create mock device
device = MockDevice()

# Send commands and get simulated responses
response = device.query("STATUS")
print(response.type)  # "mock"
print(response.status)  # "ok"

# Queue detection data for testing
device.queue_data(85, 90, 88)
data = device.receive_response(field_type="data")

Installation

Quick Start

# Get the release
git checkout v0.1.1

# Install dependencies
uv sync

# Test with mock device
kazunoko info --mock

What's Different from the Last Version?

✅ Added

  • MockDevice class implementing DeviceProtocol for testing without hardware
  • --mock flag to all CLI commands (send, listen, info)
  • DeviceProtocol (typing.Protocol) for device interface consistency
  • FIELD_TYPE_MOCK constant for distinguishing mock responses
  • Sample detection data queuing in listen command's mock mode
  • Helper function _get_device() for seamless real/mock device switching

🔧 Changed

  • Refactored device layer with Protocol interface
  • Renamed protocol.py to parser.py for clarity (parser is JSONL-specific)
  • Updated documentation and examples to show mock mode usage

🐛 Fixed

  • None (feature release)

Is It Safe to Upgrade?

Backward Compatible: Yes

  • All existing PortDevice and connect() functionality remains unchanged
  • New MockDevice is opt-in via --mock flag
  • Protocol interface addition is backward compatible (no breaking changes)
  • Renaming protocol.py → parser.py is internal (imports updated automatically)

Tests Passed

  • ✅ Builds without errors
  • ✅ All CLI commands work with --mock flag
  • ✅ MockDevice simulates all standard commands correctly
  • ✅ Protocol interface validated with both PortDevice and MockDevice
  • ✅ Documentation and examples updated

Release Details

  • Date: 2025-12-01
  • Version: v0.1.1
  • Files Changed: 6 files
  • Commits: 7 commits
  • feat: add DeviceProtocol interface for device implementations
  • feat: add MockDevice for testing without hardware
  • feat: add --mock option to CLI commands for testing
  • feat: use FIELD_TYPE_MOCK for mock device responses
  • docs: update README and CLAUDE.md for refactoring

Next Steps

Future improvements planned: - Write comprehensive tests for MockDevice - Add integration tests using MockDevice - Expand MockDevice to simulate error conditions - Consider async device support - Add data export and logging features