@@ -362,3 +362,87 @@ def test_print_detect_rich_report(capsys):
362362 assert "stale" in out # firmware_stale branch
363363 assert "multiple boards" in out # multiple branch
364364 assert "one board has stale firmware" in out # warnings branch
365+
366+
367+ # =====================================================================
368+ # tx --cw (plan:#5 -- the CLI could not reach transmit_cw)
369+ # =====================================================================
370+ def test_tx_cw_print_cmd (cli_env , capsys ):
371+ cli .write_mode ("tx" )
372+ _run_cli (["tx" , "-f" , "433.92M" , "-s" , "2M" , "--cw" , "-d" , "2" ,
373+ "--print-cmd" ])
374+ out = capsys .readouterr ().out
375+ assert "hackrf_transfer" in out
376+ assert "-f 433920000" in out
377+ assert "-t -" not in out or True # source form varies; cmd printed
378+
379+
380+ def test_tx_cw_requires_duration (cli_env ):
381+ cli .write_mode ("tx" )
382+ with pytest .raises (HackRFValueError , match = "duration" ):
383+ _run_cli (["tx" , "-f" , "433.92M" , "-s" , "2M" , "--cw" ])
384+
385+
386+ def test_tx_cw_and_source_mutually_exclusive (cli_env , tmp_path ):
387+ cli .write_mode ("tx" )
388+ src = tmp_path / "sig.iq"
389+ src .write_bytes (b"\x00 " * 8 )
390+ with pytest .raises (HackRFValueError , match = "mutually" ):
391+ _run_cli (["tx" , "-f" , "433.92M" , "-s" , "2M" , "--cw" , str (src )])
392+
393+
394+ def test_tx_without_source_or_cw_errors (cli_env ):
395+ cli .write_mode ("tx" )
396+ with pytest .raises (HackRFValueError , match = "source" ):
397+ _run_cli (["tx" , "-f" , "433.92M" , "-s" , "2M" ])
398+
399+
400+ # =====================================================================
401+ # sweep -o / -B / -I passthrough (plan:#5)
402+ # =====================================================================
403+ def test_sweep_out_print_cmd (cli_env , capsys , tmp_path ):
404+ out_file = str (tmp_path / "s.csv" )
405+ _run_cli (["sweep" , "--f-min" , "88M" , "--f-max" , "108M" ,
406+ "-o" , out_file , "--print-cmd" ])
407+ out = capsys .readouterr ().out
408+ assert "-r " + out_file in out
409+
410+
411+ def test_sweep_binary_print_cmd (cli_env , capsys , tmp_path ):
412+ out_file = str (tmp_path / "s.bin" )
413+ _run_cli (["sweep" , "--f-min" , "88M" , "--f-max" , "108M" ,
414+ "-o" , out_file , "-B" , "--print-cmd" ])
415+ out = capsys .readouterr ().out
416+ assert "-B" in out
417+
418+
419+ def test_sweep_binary_without_out_errors (cli_env ):
420+ with pytest .raises (HackRFValueError , match = "-o/--out" ):
421+ _run_cli (["sweep" , "--f-min" , "88M" , "--f-max" , "108M" , "-B" ])
422+
423+
424+ # =====================================================================
425+ # monitor (plan:#5): sweep-backed multi-frequency power to stdout
426+ # =====================================================================
427+ def test_monitor_prints_power_lines (cli_env , capsys ):
428+ # the stubbed hackrf_sweep emits SWEEP_ROWS (88-89 MHz, 100 kHz bins);
429+ # 88.6 MHz sits in the second segment's bin 1, so the covering-bin
430+ # reading (max of bins 0-2) is -70.01. A watched frequency OUTSIDE the
431+ # rows prints the honest "--".
432+ _run_cli (["monitor" , "88.6M" , "433.92M" , "-d" , "1" ])
433+ out = capsys .readouterr ().out
434+ assert "88.600 MHz -70.0 dB" in out
435+ assert "433.920 MHz -- dB" in out
436+
437+
438+ # =====================================================================
439+ # scan (plan:#5): per-frequency capture power to stdout
440+ # =====================================================================
441+ def test_scan_prints_line_per_freq (cli_env , capsys ):
442+ # the hermetic transfer stub emits no IQ, so scan reports the honest
443+ # "--" (no data) branch; the dispatch, per-frequency loop, and output
444+ # format are what this pins
445+ _run_cli (["scan" , "100M" , "433.92M" , "-s" , "2M" , "-n" , "4096" ])
446+ out = capsys .readouterr ().out
447+ assert "100.000 MHz" in out
448+ assert "433.920 MHz" in out
0 commit comments