Skip to content

Updating Mock Data

MockDevice loads device responses and detection events from files bundled inside the package:

src/kazunoko/data/
├── responses/       # One JSON file per device command
│   ├── get_status.json
│   ├── get_version.json
│   ├── get_threshold.json
│   └── ...
└── events/
    └── events.jsonl  # Detection events for MockGenerator

When the mock data becomes outdated (e.g. after a firmware update), update these files with real device data.


Update response files

Each file in data/responses/ corresponds to one device command and contains the JSON response from a real device.

Capture a response

# Capture a single command response
kazunoko query GET_STATUS --format json > /tmp/get_status.json

# Verify it looks correct
cat /tmp/get_status.json

Save to the package

cp /tmp/get_status.json src/kazunoko/data/responses/get_status.json

Repeat for each command you want to update:

File Command
get_status.json GET_STATUS
get_version.json GET_VERSION
get_mac_address.json GET_MAC_ADDRESS
get_uptime.json GET_UPTIME
get_threshold.json GET_THRESHOLD 1
get_poll_count.json GET_POLL_COUNT
get_rtc_time.json GET_RTC_TIME
get_usage.json GET_USAGE
set_threshold.json SET_THRESHOLD 1 300
set_poll_count.json SET_POLL_COUNT 100
set_rtc_time.json SET_RTC_TIME <value>

Update the events file

data/events/events.jsonl provides the detection events replayed by MockGenerator.from_random() and MockDevice.

Capture events from a real detector

# Collect 1000 events and save to the package
kazunoko measure "1:300;2:360;3:330" 1000 > src/kazunoko/data/events/events.jsonl

Use representative data

Collect events at typical operating thresholds so that mock behavior reflects real detector output.

Verify the file

wc -l src/kazunoko/data/events/events.jsonl
head -1 src/kazunoko/data/events/events.jsonl | python3 -m json.tool

Verify mock behavior after updating

# Check that MockDevice loads correctly
kazunoko status --mock

# Check that events are replayed
kazunoko read 10 --mock

# Check that measure works end-to-end
kazunoko measure "1:300;2:360;3:330" 10 --mock