53 lines
1.5 KiB
Python
53 lines
1.5 KiB
Python
from __future__ import annotations
|
|
|
|
import subprocess
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
from rfg_adc_plotter.cli import build_parser
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def _run(*args: str) -> subprocess.CompletedProcess[str]:
|
|
return subprocess.run(
|
|
[sys.executable, *args],
|
|
cwd=ROOT,
|
|
text=True,
|
|
capture_output=True,
|
|
check=False,
|
|
)
|
|
|
|
|
|
class CliTests(unittest.TestCase):
|
|
def test_logscale_is_opt_in(self):
|
|
args = build_parser().parse_args(["/dev/null"])
|
|
self.assertFalse(args.logscale)
|
|
|
|
args_log = build_parser().parse_args(["/dev/null", "--logscale"])
|
|
self.assertTrue(args_log.logscale)
|
|
|
|
def test_wrapper_help_works(self):
|
|
proc = _run("RFG_ADC_dataplotter.py", "--help")
|
|
self.assertEqual(proc.returncode, 0)
|
|
self.assertIn("usage:", proc.stdout)
|
|
self.assertIn("--peak_search", proc.stdout)
|
|
|
|
def test_module_help_works(self):
|
|
proc = _run("-m", "rfg_adc_plotter.main", "--help")
|
|
self.assertEqual(proc.returncode, 0)
|
|
self.assertIn("usage:", proc.stdout)
|
|
self.assertIn("--parser_16_bit_x2", proc.stdout)
|
|
self.assertIn("--parser_complex_ascii", proc.stdout)
|
|
|
|
def test_backend_mpl_reports_removal(self):
|
|
proc = _run("-m", "rfg_adc_plotter.main", "/dev/null", "--backend", "mpl")
|
|
self.assertNotEqual(proc.returncode, 0)
|
|
self.assertIn("Matplotlib backend removed", proc.stderr)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|