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.
This commit is contained in:
1 parent
dbed9bbc88
commit
917522d1f4
12 files changed
+1861
No files matched your search
@@ -0,0 +1,46 @@
|
||||
"""The rb9704 command line against the fake modem."""
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def run(*args, timeout=30):
|
||||
return subprocess.run([sys.executable, "-m", "rb9704tools.cli", *args], capture_output=True,
|
||||
text=True, timeout=timeout)
|
||||
|
||||
|
||||
def test_jspr_raw(fake):
|
||||
r = run("-p", fake.port, "jspr", "--setup", "GET hwInfo {}")
|
||||
assert r.returncode == 0, r.stderr
|
||||
assert "300434030000000" in r.stdout
|
||||
|
||||
|
||||
def test_provision_sees_topics(fake):
|
||||
r = run("-p", fake.port, "provision", "--timeout", "10")
|
||||
assert r.returncode == 0, r.stdout + r.stderr
|
||||
assert "244" in r.stdout
|
||||
|
||||
|
||||
def test_info_through_the_library(fake):
|
||||
pytest.importorskip("rockblock9704")
|
||||
r = run("-p", fake.port, "info")
|
||||
assert r.returncode == 0, r.stderr
|
||||
assert "300434030000000" in r.stdout
|
||||
|
||||
|
||||
def test_send_asks_first(fake):
|
||||
pytest.importorskip("rockblock9704")
|
||||
r = subprocess.run([sys.executable, "-m", "rb9704tools.cli", "-p", fake.port, "send",
|
||||
"--text", "x"], input="n\n", capture_output=True, text=True, timeout=30)
|
||||
assert "airtime" in (r.stdout + r.stderr).lower()
|
||||
assert not any(l.startswith("MO ") for l in fake.out.seen)
|
||||
|
||||
|
||||
def test_send_with_yes(fake):
|
||||
pytest.importorskip("rockblock9704")
|
||||
r = run("-p", fake.port, "send", "--text", "cli-hello", "--yes")
|
||||
assert r.returncode == 0, r.stdout + r.stderr
|
||||
m = fake.out.expect(r"^MO 244 \d+ (\w+)")
|
||||
assert bytes.fromhex(m.group(1)) == b"cli-hello"
|
||||
Reference in new issue
Block a user