Files
rockblock9704-zephyr/python/tests/test_real.py
T
scottp 917522d1f4 Python: the rb9704 command line, a fake modem, and the tests
rb9704 drives a 9704 on USB and the Cloudloop account behind it, moved
from WII6's host/rockblock with its project names taken out. rb9704-fake
speaks JSPR on a pty or a serial port: everything the library asks, MO in
segments with the CRC checked, MT, signal, provisioning, refusals and
failures on command.

The tests run against the fake at every level: the fake itself, the
command line, Ground Control's Python binding, the shell sample on
native_sim, and the sample on a board (test_zephyr.py, one suite through
two consoles). test_real.py makes free checks against a real modem.
2026-10-09 12:48:16 +11:00

50 lines
1.2 KiB
Python

"""
A real RockBLOCK 9704, with --real-modem PORT. Free checks only: identity
and signal, never a message, so nothing here costs airtime. Indoors the
signal is usually 0, which passes.
"""
import re
import pytest
from conftest import NativeConsole
@pytest.fixture
def real(request):
port = request.config.getoption("--real-modem")
if not port:
pytest.skip("no --real-modem")
return port
def test_library_identity(real):
rb = pytest.importorskip("rockblock9704")
m = rb.RockBlock9704()
assert m.begin(real)
try:
assert re.fullmatch(r"\d{15}", m.get_imei() or "")
assert m.get_card_present()
assert 0 <= m.get_signal() <= 5
finally:
m.end()
def test_zephyr_native_sim_identity(real, request):
exe = request.config.getoption("--zephyr-exe")
if not exe:
pytest.skip("no --zephyr-exe")
c = NativeConsole(exe, real)
try:
c.sh("rb9704 begin")
c.out.expect(r"begin: ok", timeout=20)
c.sh("rb9704 info")
c.out.expect(r"imei\s+\d{15}", timeout=20)
c.sh("rb9704 signal")
c.out.expect(r"signal: [0-5] bars", timeout=20)
c.sh("rb9704 end")
c.out.expect(r"end: ok")
finally:
c.close()