Files
beefy-player/tests/test_mediasession.py
T
beefcarver e30ca09627 refactor!: rename somafm-tui to beefy-player
The app is now a general internet-radio player rather than a SomaFM client, so the package, console script, MPRIS identity, mpv namespaces, macOS tap names, XDG directories and docs all move to beefy-player.

Environment variables are now BEEFY_* (the old SOMAFM_* spellings are still honoured) and an existing ~/.config/somafm-tui/config.json is migrated on first run, so favourites and volume survive the rename.

The visible interface is untouched: same layout, same logo, same keys.
2026-11-03 16:10:25 -05:00

57 lines
1.7 KiB
Python

from __future__ import annotations
import queue
import sys
from beefy_player import mediasession
from beefy_player.mediasession import (
MediaSession,
NowPlayingSession,
create_media_session,
)
def test_linux_uses_mpris() -> None:
from beefy_player.mpris import MprisService
session = create_media_session(queue.Queue(), enabled=False, platform="linux")
assert isinstance(session, MprisService)
assert session.label == "mpris"
def test_macos_uses_the_system_now_playing_session() -> None:
session = create_media_session(
queue.Queue(), enabled=True, backend="mpv", platform="darwin"
)
assert isinstance(session, NowPlayingSession)
assert session.label == "nowplaying"
assert session.status_label == "on"
def test_macos_without_mpv_reports_off() -> None:
session = create_media_session(
queue.Queue(), enabled=True, backend="ffplay", platform="darwin"
)
assert session.status_label == "off"
def test_disabled_session_is_inert_but_keeps_state() -> None:
actions: queue.Queue[str] = queue.Queue()
session = MediaSession(actions, enabled=False)
session.start()
session.set_status("Playing")
session.set_volume(1.7)
session.set_track(station="Groove Salad", title="T", artist="A", album="B")
session.stop()
assert session.status_label == "off"
assert session._status == "Playing"
assert session._volume == 1.0
assert session._metadata["album"] == "B"
assert actions.empty()
def test_platform_detection_is_available_for_tests() -> None:
# The factory must never import D-Bus code on a platform without it.
assert "linux" in sys.platform or sys.platform == "darwin"
assert mediasession.media_actions_queue().empty()