Phase 1 of package refactor. Moves all source modules into pm3py/core/ with file renames (hf_14a→hf_iso14a, hf_15→hf_iso15, hf_mf→hf_mfc) and client attribute normalization (hf.a14→hf.iso14a, hf.mf→hf.mfc). pm3py/__init__.py re-exports from core for backward compat. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
28 lines
1.0 KiB
Python
28 lines
1.0 KiB
Python
import struct
|
|
import asyncio
|
|
from unittest.mock import AsyncMock
|
|
from pm3py.core.protocol import Cmd
|
|
from pm3py.core.transport import PM3Response
|
|
from pm3py.core.lf import LFCommands
|
|
|
|
def make_response(cmd, status, data):
|
|
return PM3Response(cmd=cmd, status=status, reason=0, ng=True, data=data)
|
|
|
|
def test_lf_tune():
|
|
t = AsyncMock()
|
|
lf = LFCommands(t)
|
|
# First call: init, second call: poll returns data
|
|
t.send_ng.return_value = make_response(Cmd.MEASURE_ANTENNA_TUNING_LF, 0,
|
|
struct.pack("<I", 42000))
|
|
result = asyncio.get_event_loop().run_until_complete(lf.tune(divisor=95))
|
|
assert "voltage_mV" in result
|
|
|
|
def test_lf_config_get():
|
|
t = AsyncMock()
|
|
lf = LFCommands(t)
|
|
payload = struct.pack("<bbbhhib", 1, 8, 1, 95, 128, 0, 0)
|
|
t.send_ng.return_value = make_response(Cmd.LF_SAMPLING_GET_CONFIG, 0, payload)
|
|
result = asyncio.get_event_loop().run_until_complete(lf.config())
|
|
assert "decimation" in result
|
|
assert "bits_per_sample" in result
|