2026-10-30 04:17:54 +00:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-11-03 16:10:30 -05:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from beefy_player.__main__ import _build_parser, _list_stations
|
2026-10-30 04:17:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_parser_defaults_and_flags() -> None:
|
|
|
|
|
parser = _build_parser()
|
|
|
|
|
args = parser.parse_args([])
|
|
|
|
|
assert args.autoplay is None
|
|
|
|
|
assert args.offline is False
|
|
|
|
|
assert args.no_audio is False
|
|
|
|
|
|
|
|
|
|
assert args.spectrum_source == "auto"
|
|
|
|
|
|
|
|
|
|
args = parser.parse_args(
|
|
|
|
|
["--station", "defcon", "--play", "--no-mpris", "--spectrum-source", "monitor"]
|
|
|
|
|
)
|
|
|
|
|
assert args.station == "defcon"
|
|
|
|
|
assert args.autoplay is True
|
|
|
|
|
assert args.no_mpris is True
|
|
|
|
|
assert args.spectrum_source == "monitor"
|
2026-11-03 16:10:30 -05:00
|
|
|
assert args.provider is None # the config file decides
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_provider_flag_is_validated() -> None:
|
|
|
|
|
parser = _build_parser()
|
|
|
|
|
assert parser.parse_args(["--provider", "somafm"]).provider == "somafm"
|
|
|
|
|
with pytest.raises(SystemExit):
|
|
|
|
|
parser.parse_args(["--provider", "no-such-catalogue"])
|
2026-10-30 04:17:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_list_stations_offline(capsys) -> None:
|
|
|
|
|
assert _list_stations(offline=True) == 0
|
|
|
|
|
output = capsys.readouterr().out
|
|
|
|
|
assert "groovesalad" in output
|
|
|
|
|
assert "Groove Salad" in output
|