test_radio_lesson.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. # SPDX-License-Identifier: Apache-2.0
  2. """The radio and off-grid communication lesson: its script runs, its citations exist, it is registered and it stays safe.
  3. docs/wiki/Radio-Off-Grid-Communication-LoRa-Meshtastic-Reticulum-Ham-and-SIGINT.md teaches radio as a continuity fallback
  4. and tells this project's own story honestly (no radio code exists). A script whose output differs from the page, a cited
  5. file that does not exist, a missing registration, a real callsign or grid square, a command that would configure a radio
  6. or a link that pushes another lesson over its link cap would each teach the wrong thing.
  7. """
  8. import importlib.util
  9. import math
  10. import re
  11. import subprocess
  12. import sys
  13. from pathlib import Path
  14. from wikitext import page_text
  15. ROOT = Path(__file__).resolve().parent.parent
  16. WIKI = ROOT / "docs" / "wiki"
  17. NAME = "Radio-Off-Grid-Communication-LoRa-Meshtastic-Reticulum-Ham-and-SIGINT"
  18. PAGE = WIKI / f"{NAME}.md"
  19. FENCE = re.compile(r"^[ ]*```(\w*)\n(.*?)^[ ]*```$", re.MULTILINE | re.DOTALL)
  20. LINK = re.compile(r"\]\(([A-Za-z0-9_-]+)\.md(?:#[^)]*)?\)")
  21. ADDR = re.compile(r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
  22. PATH_TOKEN = re.compile(r"`((?:modules|stacks|scripts|docs|\.github|\.spacelift|tests)/[A-Za-z0-9_./-]+)`")
  23. STATUS_WORDS = ("Read", "Observed", "Not read", "Not run", "General knowledge", "**est.**", "Stated by the maintainer")
  24. CALLSIGN = re.compile(r"\b(?:[AKNW][A-Z]?)\d[A-Z]{1,3}\b")
  25. GRID = re.compile(r"\b[A-R]{2}\d{2}(?:[a-x]{2})?\b")
  26. RADIO_TOOLS = re.compile(r"\b(?:meshtastic|rnodeconf|rnsd|rnstatus|lxmd|rtl_fm|hackrf_transfer|flrig|rigctl|fldigi|direwolf)\b")
  27. BLAST = "Plan-for-Failure-Blast-Radius-and-Assuming-Breach"
  28. TOPICS = (
  29. "## When the internet and the power go out: what still works",
  30. "## Wi-Fi, and why it is not the only radio",
  31. "## LoRa, Meshtastic, MeshCore and Reticulum",
  32. "## Amateur (ham) radio",
  33. "## GMRS and FRS",
  34. "## Citizens band (CB)",
  35. "## Signals intelligence (SIGINT): a careful overview",
  36. "## Why radio is a common hobby among security people",
  37. "## Radio in a continuity plan for this project",
  38. "## Free exercises: offline, listen-only and simulation",
  39. "## Claims register",
  40. )
  41. def text() -> str:
  42. return PAGE.read_text(encoding="utf-8")
  43. def section(body: str, start: str, end: str) -> str:
  44. return body.split(start)[1].split(end)[0]
  45. def table_rows(block: str) -> list[list[str]]:
  46. rows = [line for line in block.splitlines() if line.startswith("|") and not line.startswith("|---")]
  47. return [[c.strip() for c in r.strip("|").split("|")] for r in rows[1:]]
  48. def cited_paths(cell: str) -> list[str]:
  49. return PATH_TOKEN.findall(cell)
  50. def register_rows(body: str) -> list[list[str]]:
  51. return table_rows(body.split("## Claims register")[1])
  52. def rows_missing_status(rows: list[list[str]]) -> list[str]:
  53. return [r[0] for r in rows if not any(w in r[-1] for w in STATUS_WORDS)]
  54. def rows_missing_citation(rows: list[list[str]]) -> list[str]:
  55. """A project row cites files that exist, or its file column starts with None and its status says None."""
  56. bad = []
  57. for r in rows:
  58. files, status = r[4], r[5]
  59. paths = cited_paths(files)
  60. if any(not (ROOT / p).exists() for p in paths):
  61. bad.append(r[0])
  62. elif files.startswith("None"):
  63. if "None" not in status:
  64. bad.append(r[0])
  65. elif not paths:
  66. bad.append(r[0])
  67. return bad
  68. def foreign_callsigns(body: str) -> list[str]:
  69. return sorted(set(CALLSIGN.findall(body)) - {"N0CALL", "N0TST"})
  70. def foreign_grids(body: str) -> list[str]:
  71. return sorted(set(GRID.findall(body)) - {"FN31pr"})
  72. def radio_commands_in_shell_blocks(body: str) -> list[str]:
  73. return [b for t, b in FENCE.findall(body) if t in ("bash", "sh", "shell", "console") and RADIO_TOOLS.search(b)]
  74. def script_source() -> str:
  75. found = [b for t, b in FENCE.findall(text()) if t == "python" and "# lora_budget.py - " in b]
  76. assert len(found) == 1, f"expected one lora_budget.py block, found {len(found)}"
  77. return found[0]
  78. def run_script(tmp: Path, *args: str) -> subprocess.CompletedProcess:
  79. path = tmp / "lora_budget.py"
  80. path.write_text(script_source(), encoding="utf-8")
  81. return subprocess.run([sys.executable, "-I", str(path), *args], capture_output=True, text=True, timeout=60, check=False, cwd=tmp)
  82. def load_functions(tmp: Path) -> dict:
  83. """Import the page's script as a module, with its final main() call removed so importing it prints nothing."""
  84. path = tmp / "lora_budget_under_test.py"
  85. path.write_text(script_source().rsplit("\nmain()", 1)[0] + "\n", encoding="utf-8")
  86. spec = importlib.util.spec_from_file_location("lora_budget_under_test", path)
  87. assert spec and spec.loader
  88. module = importlib.util.module_from_spec(spec)
  89. spec.loader.exec_module(module)
  90. return vars(module)
  91. def same_lines(got: str, want: str) -> bool:
  92. return [line.rstrip() for line in got.strip().splitlines()] == [line.rstrip() for line in want.strip().splitlines()]
  93. def test_the_banner_says_what_was_and_was_not_run():
  94. body = text()
  95. assert body.startswith("# Radio and off-grid communication")
  96. assert "Status: unverified draft" in body
  97. assert "**Not run:**" in body and "2026-10-31" in body
  98. assert "no transmitter was keyed" in body and "no radio was configured" in body
  99. assert "General class" in body
  100. def test_every_topic_the_issue_asked_for_has_a_section():
  101. body = text()
  102. missing = [t for t in TOPICS if f"\n{t}\n" not in body]
  103. assert not missing, missing
  104. def test_every_linked_wiki_page_exists():
  105. links = set(LINK.findall(text()))
  106. assert len(links) >= 6, "the guard collected too few links"
  107. missing = sorted(t for t in links if not (WIKI / f"{t}.md").exists())
  108. assert not missing, missing
  109. def test_the_continuity_and_cryptography_lessons_are_linked_and_the_capped_one_is_plain_text():
  110. body = page_text(PAGE) # the author's text, without the generated navigation blocks (issue #417)
  111. assert "Business-Continuity-and-Disaster-Recovery-BCP-and-DR.md" in body
  112. assert "The-CIA-Triad-Confidentiality-Integrity-Availability.md" in body
  113. # the cryptography lesson (issue 360) is in the wiki, so it is linked; the blast radius lesson has a link cap that is full
  114. assert "cryptography lesson" in body
  115. crypto = "Cryptography-Fundamentals-Symmetric-Asymmetric-Hashing-Certificates-and-Keys"
  116. assert f"]({crypto}.md)" in body and (WIKI / f"{crypto}.md").is_file()
  117. assert "may not be merged yet" not in body
  118. assert f"{BLAST}.md" not in body
  119. assert "blast radius and assuming breach" in body
  120. def test_the_lesson_is_registered_in_contents_and_reading_order_not_the_sidebar():
  121. nav = (WIKI / "_nav.yaml").read_text(encoding="utf-8")
  122. entry = nav.split(f"page: {NAME},")[1].split("\n")[0]
  123. assert 'status: "draft"' in entry
  124. assert "sidebar" not in entry, "new lessons are reached from Contents and Reading Order, not the sidebar"
  125. for special in ("Contents.md", "Reading-Order.md"):
  126. assert f"{NAME}.md" in (WIKI / special).read_text(encoding="utf-8"), special
  127. rows = [line for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines() if f"{NAME}.md" in line]
  128. assert len(rows) >= 8, "expected glossary rows for the new terms"
  129. def test_glossary_rows_point_at_real_headings():
  130. heads = {re.sub(r"[^a-z0-9-]", "", h.lower().replace(" ", "-")) for h in re.findall(r"^#+ (.+)$", text(), re.MULTILINE)}
  131. anchors: set[str] = set()
  132. for line in (WIKI / "Glossary.md").read_text(encoding="utf-8").splitlines():
  133. anchors.update(re.findall(rf"{NAME}\.md#([a-z0-9-]+)", line))
  134. assert anchors, "the guard collected nothing"
  135. assert anchors <= heads, sorted(anchors - heads)
  136. def test_related_lessons_link_the_new_one():
  137. skip = {"Glossary.md", "_Sidebar.md", "Reading-Order.md", "Contents.md", PAGE.name}
  138. inbound = [p.name for p in WIKI.glob("*.md") if p.name not in skip and f"{NAME}.md" in p.read_text(encoding="utf-8")]
  139. assert len(inbound) >= 2, inbound
  140. def test_no_addresses_and_no_em_dashes():
  141. body = text()
  142. assert not ADDR.findall(body), set(ADDR.findall(body))
  143. assert "—" not in body
  144. assert "Meshtastic" in body, "the guard collected nothing"
  145. def test_the_address_guard_bites():
  146. assert ADDR.findall("ping 192.0.2.7")
  147. def test_only_placeholder_callsigns_and_grids_appear_anywhere_in_the_lesson_files():
  148. body = text()
  149. assert "N0CALL" in body and "N0TST" in body and "FN31pr" in body, "the guard collected nothing"
  150. assert not foreign_callsigns(body), foreign_callsigns(body)
  151. assert not foreign_grids(body), foreign_grids(body)
  152. code = script_source()
  153. assert not foreign_callsigns(code) and not foreign_grids(code)
  154. def test_the_callsign_and_grid_guards_bite():
  155. assert foreign_callsigns("de W1ABC and N0CALL") == ["W1ABC"]
  156. assert foreign_callsigns("KD9XYZ") == ["KD9XYZ"]
  157. assert foreign_grids("grid FN42ab and FN31pr") == ["FN42ab"]
  158. assert foreign_callsigns("N0CALL N0TST") == [] and foreign_grids("FN31pr") == []
  159. def test_no_exercise_runs_a_radio_tool():
  160. body = text()
  161. assert not radio_commands_in_shell_blocks(body), radio_commands_in_shell_blocks(body)
  162. section_ex = body.split("## Free exercises: offline, listen-only and simulation")[1].split("## Checkpoint")[0]
  163. assert "never transmit" in section_ex.lower() or "no exercise transmits" in section_ex.lower()
  164. assert "do not key a transmitter" in body.lower() or "never key a transmitter" in body.lower()
  165. def test_the_radio_tool_guard_bites():
  166. bad = "```bash\nmeshtastic --set lora.region US\n```\n"
  167. assert radio_commands_in_shell_blocks(bad)
  168. assert not radio_commands_in_shell_blocks("```text\nlora.region: US\n```\n")
  169. def test_the_script_output_on_the_page_matches_a_real_run(tmp_path):
  170. body = text()
  171. shown = [b for t, b in FENCE.findall(body) if t == "text" and b.startswith("== 1. Bit rate")]
  172. assert len(shown) == 1, "expected the full report once"
  173. done = run_script(tmp_path)
  174. assert done.returncode == 0, done.stderr
  175. assert same_lines(done.stdout, shown[0])
  176. assert not [p for p in tmp_path.iterdir() if p.name != "lora_budget.py"], "the script must write nothing"
  177. def test_the_one_packet_example_matches_a_real_run(tmp_path):
  178. body = text()
  179. done = run_script(tmp_path, "--sf", "8", "--bw", "125", "--cr", "5", "--payload", "100")
  180. assert done.returncode == 0, done.stderr
  181. assert done.stdout.strip() == "SF8 BW125 CR4/5, 100 bytes: 324 ms on air, raw rate 3125 bps"
  182. assert done.stdout.strip() in body
  183. again = run_script(tmp_path, "--sf", "11", "--bw", "250", "--cr", "5", "--payload", "100")
  184. assert again.stdout.strip() == "SF11 BW250 CR4/5, 100 bytes: 1010 ms on air, raw rate 1074 bps"
  185. assert again.stdout.strip() in body
  186. def test_the_comparison_guard_bites():
  187. assert same_lines("a\nb ", "a\nb")
  188. assert not same_lines("a\nb", "a\nc")
  189. def test_the_script_matches_the_published_preset_table_and_the_semtech_formula(tmp_path):
  190. ns = load_functions(tmp_path)
  191. for name, (sf, bw, cr, pub, _) in ns["PRESETS"].items():
  192. assert abs(ns["bit_rate"](sf, bw, cr) / 1000 - pub) < 0.01, name
  193. # The datasheet form of the formula, written independently with floats and math.ceil.
  194. for sf in range(7, 13):
  195. for bw in (125, 250, 500):
  196. for cr in (5, 6, 7, 8):
  197. for total in (1, 20, 55, 100, 255):
  198. t_sym = 2**sf / (bw * 1000)
  199. de = 1 if t_sym > 0.016 else 0
  200. sym = 16 + 4.25 + 8 + max(math.ceil((8 * total - 4 * sf + 28 + 16) / (4 * (sf - 2 * de))) * cr, 0)
  201. assert abs(ns["airtime_ms"](sf, bw, cr, total) - sym * t_sym * 1000) < 1e-6, (sf, bw, cr, total)
  202. def test_the_script_refuses_half_an_override(tmp_path):
  203. done = run_script(tmp_path, "--sf", "8")
  204. assert done.returncode != 0 and "--sf needs" in done.stderr
  205. def test_the_script_cannot_reach_a_radio_or_the_network():
  206. code = script_source()
  207. for banned in ("import socket", "import subprocess", "import serial", "import os", "open(", "urllib", "requests", "sys.argv"):
  208. assert banned not in code, banned
  209. def test_every_claims_register_row_has_a_status():
  210. rows = register_rows(text())
  211. assert len(rows) >= 28, "the guard collected too few rows"
  212. assert not rows_missing_status(rows)
  213. joined = " ".join(r[1] for r in rows)
  214. for needle in ("meshtastic.org", "reticulum.network", "ecfr.gov", "law.cornell.edu", "arrl.org", "ready.gov", "intelligence.gov", "hamvillage.org", "meshcore"):
  215. assert needle in joined, needle
  216. assert sum("2026-10-31" in r[-1] for r in rows) >= 15
  217. def test_the_register_guard_bites():
  218. assert rows_missing_status([["X", "y", "maybe"]]) == ["X"]
  219. def test_the_unread_sources_are_named_as_unread():
  220. reg = text().split("## Claims register")[1]
  221. for needle in ("fcc.gov", "nsa.gov"):
  222. row = next((line for line in reg.splitlines() if needle in line), "")
  223. assert "Not read" in row, needle
  224. assert "Access Denied" in row or "403" in row, needle
  225. def test_project_rows_cite_existing_files_or_say_none():
  226. block = section(text(), "## Radio in a continuity plan for this project", "Honest summary")
  227. rows = table_rows(block)
  228. assert len(rows) >= 8, "the guard collected too few rows"
  229. assert not rows_missing_citation(rows)
  230. assert sum(r[4].startswith("None") for r in rows) >= 4, "the table must say None where nothing exists"
  231. joined = " ".join(r[0] for r in rows)
  232. for want in ("repository", "secret store", "Spacelift", "Twingate", "connectors", "wiki", "home logging", "edge"):
  233. assert want in joined, want
  234. def test_the_citation_guard_bites():
  235. rows = [
  236. ["a", "x", "x", "x", "`scripts/does_not_exist.py`", "Built"],
  237. ["b", "x", "x", "x", "`scripts/secret_rule.py`", "Built"],
  238. ["c", "x", "x", "x", "None here", "Built"],
  239. ["d", "x", "x", "x", "None; the design is in `docs/does/not/exist.md`", "None"],
  240. ["e", "x", "x", "x", "no path at all", "Built"],
  241. ]
  242. assert rows_missing_citation(rows) == ["a", "c", "d", "e"]
  243. def test_every_repository_path_the_page_names_exists():
  244. paths = set(cited_paths(text()))
  245. assert len(paths) >= 6, "the guard collected too few paths"
  246. assert not [p for p in sorted(paths) if not (ROOT / p).exists()]
  247. def test_the_page_says_this_project_has_no_radio_integration():
  248. section_text = text().split("## Radio in a continuity plan for this project")[1].split("## Free exercises")[0]
  249. assert "no radio" in section_text.lower()
  250. assert "None" in section_text
  251. assert "TCP" in section_text, "the edge design carries Reticulum over TCP, which is not radio"
  252. def test_the_legal_rules_come_before_the_overview_in_the_sigint_section():
  253. sec = text().split("## Signals intelligence (SIGINT): a careful overview")[1].split("## Why radio is a common hobby")[0]
  254. legal = sec.index("### The legal rules first")
  255. what = sec.index("### What SIGINT is")
  256. assert legal < what
  257. for needle in ("2511", "605", "check your own jurisdiction", "not legal advice", "readily accessible"):
  258. assert needle in sec, needle
  259. def test_the_maintainer_facts_are_only_the_allowed_ones_and_no_to_do_list_is_published():
  260. body = text()
  261. assert "Maintainer notes to add" not in body
  262. assert "beyond the license class and the five services" in body
  263. assert "Meshtastic, MeshCore, Reticulum, ham radio and GMRS" in body
  264. assert "General class" in body
  265. assert not re.search(r"\b(?:my|his) (?:node|radio|repeater|antenna|rig)s?\b", body, re.IGNORECASE)
  266. def test_us_rules_are_dated_and_other_countries_are_pointed_to_their_regulator():
  267. body = text()
  268. assert "check your own regulator" in body.lower() or "check your own country's regulator" in body.lower()
  269. assert "2026-10-29" in body, "the eCFR edition date must be stated"
  270. HALOW = "## Wi-Fi HaLow (IEEE 802.11ah) next to LoRa"
  271. HALOW_HEADS = (
  272. "### What HaLow is, and what it is not",
  273. "### HaLow compared with LoRa and the other radios on this page",
  274. "### Which to choose for off-grid and continuity use",
  275. "### HaLow rules: legal first",
  276. )
  277. HALOW_ROWS = ("Wi-Fi HaLow", "LoRa (physical layer)", "LoRaWAN", "Meshtastic", "MeshCore", "Wi-Fi at 2.4 and 5 GHz", "Amateur radio", "GMRS and FRS", "CB")
  278. def halow_section(body: str) -> str:
  279. return body.split(f"\n{HALOW}\n")[1].split("\n## Amateur (ham) radio\n")[0]
  280. def tables_in(block: str) -> list[list[str]]:
  281. """Each table's header row, found by the line before a |---| separator."""
  282. lines = block.splitlines()
  283. return [[c.strip() for c in lines[i - 1].strip("|").split("|")] for i, line in enumerate(lines) if line.startswith("|---") and i]
  284. def first_cells(block: str) -> list[str]:
  285. return [r[0].replace("**", "") for r in table_rows(block)]
  286. def test_halow_has_its_own_section_and_subsections_before_the_ham_section():
  287. body = page_text(PAGE)
  288. assert f"\n{HALOW}\n" in body
  289. assert body.index("## LoRa, Meshtastic, MeshCore and Reticulum") < body.index(HALOW) < body.index("\n## Amateur (ham) radio\n")
  290. sec = halow_section(body)
  291. for head in HALOW_HEADS:
  292. assert f"\n{head}\n" in f"\n{sec}", head
  293. def test_the_banner_and_intro_say_halow_was_added_and_what_was_not_run():
  294. body = page_text(PAGE)
  295. banner = body.split("> **Status: unverified draft.")[1].split("\n\n")[0]
  296. assert "HaLow" in banner and "2026-11-01" in banner
  297. assert "no transmitter was keyed" in banner
  298. assert "HaLow" in body.split("## What you will be able to do")[0]
  299. assert any("HaLow" in line for line in body.split("## What you will be able to do")[1].split("##")[0].splitlines())
  300. assert "Wi-Fi HaLow" in section(body, "## When the internet and the power go out: what still works", "Satellite messengers")
  301. def test_the_comparison_tables_name_their_first_cell_and_cover_every_technology_the_issue_named():
  302. sec = halow_section(page_text(PAGE))
  303. tables = tables_in(sec)
  304. assert len(tables) >= 3, "expected two comparison tables and a decision table"
  305. assert all(t[0] for t in tables), "every table needs a named first header cell"
  306. comparison = sec.split("### HaLow compared with LoRa and the other radios on this page")[1].split("### Which to choose")[0]
  307. header_text = " ".join(" ".join(t) for t in tables_in(comparison)).lower()
  308. for want in ("range", "throughput", "power", "topology", "licens", "encryption", "typical use", "equipment cost class"):
  309. assert want in header_text, want
  310. got = first_cells(comparison)
  311. for want in HALOW_ROWS:
  312. assert want in got, want
  313. def test_every_halow_figure_carries_a_source_or_a_marker_and_no_price_appears():
  314. sec = halow_section(page_text(PAGE))
  315. assert "1 km" in sec and "100 kb/s" in sec
  316. for line in sec.splitlines():
  317. if "1 km" in line or "100 kb/s" in line or "15 km" in line:
  318. assert any(w in line for w in ("vendor", "design", "theoretical", "alliance", "Alliance", "IEEE")), line
  319. assert "$" not in sec and "USD" not in sec and "dollar" not in sec.lower()
  320. assert "qualitative" in sec.lower()
  321. def test_halow_is_described_as_newer_and_less_common_and_no_vendor_is_ranked():
  322. sec = halow_section(page_text(PAGE))
  323. lowered = sec.lower()
  324. assert "newer" in lowered and "less common" in lowered
  325. for ranking in ("best", "recommended vendor", "top pick", "fastest chip"):
  326. assert ranking not in lowered, ranking
  327. def test_the_halow_legal_section_reads_the_rule_text_and_adds_no_transmission_steps():
  328. sec = halow_section(page_text(PAGE))
  329. legal = sec.split("### HaLow rules: legal first")[1]
  330. for needle in ("15.247", "902", "928", "other regions", "not legal advice", "equipment authorization"):
  331. assert needle in legal, needle
  332. assert not radio_commands_in_shell_blocks(sec)
  333. assert not re.search(r"\b(?:set|configure|enable|flash)\b[^.\n]*\b(?:transmit|power|channel|region)\b", legal, re.IGNORECASE), "no configuration steps"
  334. assert not foreign_callsigns(sec) and not foreign_grids(sec)
  335. def test_the_register_lists_the_halow_sources_read_and_the_ones_not_read():
  336. reg = page_text(PAGE).split("## Claims register")[1]
  337. for needle in ("wi-fi.org", "standards.ieee.org", "lora-alliance.org", "MorseMicro", "15.247"):
  338. row = next((line for line in reg.splitlines() if needle in line and "2026-11-01" in line), "")
  339. assert row, needle
  340. assert "Read 2026-11-01" in row, needle
  341. assert any("HaLow" in line and "Not read" in line for line in reg.splitlines()), "unread HaLow facts must be named"
  342. assert "Not verified" in page_text(PAGE) or "Not read" in page_text(PAGE)
  343. def test_the_glossary_defines_halow_once_and_sub_ghz_once_and_points_at_real_headings():
  344. glossary = (WIKI / "Glossary.md").read_text(encoding="utf-8")
  345. for term in ("Wi-Fi HaLow (IEEE 802.11ah)", "Sub-GHz band"):
  346. rows = [line for line in glossary.splitlines() if line.startswith(f"| **{term}**")]
  347. assert len(rows) == 1, (term, len(rows))
  348. assert f"{NAME}.md#" in rows[0], term
  349. assert "802.11ah" not in "".join(line for line in glossary.splitlines() if line.startswith("| **802.11ah"))
  350. def test_the_halow_table_guards_bite():
  351. assert tables_in("| A | B |\n|---|---|\n| x | y |") == [["A", "B"]]
  352. assert tables_in("| | B |\n|---|---|\n| x | y |")[0][0] == ""
  353. assert first_cells("| T | U |\n|---|---|\n| **LoRaWAN** | y |") == ["LoRaWAN"]