mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-23 12:06:28 +01:00
Some checks are pending
md-naming / markdown naming convention (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (mypy, mypy) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (pylint, pylint) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (rest, ) (push) Waiting to run
Pre-commit checks / pre-commit (${{ matrix.group }}) (shellcheck, shellcheck) (push) Waiting to run
Python tests / test (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
Shell tests / shell-tests (push) Waiting to run
Shell tests / lib-tests (push) Waiting to run
Shell tests / arch-tests (push) Waiting to run
Records every Steam game from launch to exit with gpu-screen-recorder: a jeepney D-Bus watcher on app-steam-app* scopes (game-rec-auto user unit), a $mod+Shift+g hotkey and an i3blocks dot. Failure modes: a daemon-reload no longer ends a live recording (ActiveState is re-checked before removal); a hotkey start with no matching audio stream falls back to the guessed app name and retries without it if gsr rejects it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWVxiT9Y4MhGeKGz9dX
82 lines
2.8 KiB
Python
82 lines
2.8 KiB
Python
"""Tests for linux_configuration/gaming/game_rec_dbus.py (jeepney plumbing).
|
|
|
|
``FakeConn`` (tests/test_game_rec_fakes.py) stands in for jeepney's blocking
|
|
connection; no test opens a real bus.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import game_rec_dbus as grd
|
|
from jeepney import DBusAddress, HeaderFields, new_method_return, new_signal
|
|
|
|
from tests.test_game_rec_fakes import FOX_PATH, RAT, RAT_PATH, FakeConn
|
|
|
|
|
|
class TestJeepneyBus:
|
|
"""``JeepneyBus`` maps the small bus interface onto jeepney calls."""
|
|
|
|
def test_call_targets_systemd_and_unwraps(self) -> None:
|
|
conn = FakeConn([])
|
|
bus = grd.JeepneyBus(conn)
|
|
assert bus.call(grd.MANAGER_PATH, grd.MANAGER_IFACE, "Subscribe") == ("ok",)
|
|
fields = conn.sent[0].header.fields
|
|
assert fields[HeaderFields.destination] == grd.SYSTEMD
|
|
assert fields[HeaderFields.member] == "Subscribe"
|
|
|
|
def test_matches_go_to_the_bus_daemon(self) -> None:
|
|
conn = FakeConn([])
|
|
bus = grd.JeepneyBus(conn)
|
|
rule = grd.props_rule(RAT_PATH)
|
|
bus.add_match(rule)
|
|
bus.remove_match(rule)
|
|
members = [m.header.fields[HeaderFields.member] for m in conn.sent]
|
|
assert members == ["AddMatch", "RemoveMatch"]
|
|
assert conn.sent[0].body == (rule.serialise(),)
|
|
|
|
def test_next_signal_skips_non_signals(self) -> None:
|
|
sig = new_signal(
|
|
DBusAddress(grd.MANAGER_PATH, interface=grd.MANAGER_IFACE),
|
|
"UnitNew",
|
|
"so",
|
|
(RAT, RAT_PATH),
|
|
)
|
|
reply = new_method_return(
|
|
new_signal(DBusAddress("/x", interface="org.example.I"), "m")
|
|
)
|
|
conn = FakeConn([reply, sig])
|
|
bus = grd.JeepneyBus(conn)
|
|
assert bus.next_signal() == (
|
|
grd.MANAGER_PATH,
|
|
grd.MANAGER_IFACE,
|
|
"UnitNew",
|
|
(RAT, RAT_PATH),
|
|
)
|
|
|
|
|
|
class TestJeepneyDiscard:
|
|
"""``JeepneyBus.discard_pending`` drops only that unit's queued changes."""
|
|
|
|
def test_drops_only_matching_properties_changed(self) -> None:
|
|
conn = FakeConn([])
|
|
bus = grd.JeepneyBus(conn)
|
|
props = DBusAddress(RAT_PATH, interface=grd.PROPS_IFACE)
|
|
stale = new_signal(
|
|
props, "PropertiesChanged", "sa{sv}as", (grd.UNIT_IFACE, {}, [])
|
|
)
|
|
other = new_signal(
|
|
DBusAddress(FOX_PATH, interface=grd.PROPS_IFACE),
|
|
"PropertiesChanged",
|
|
"sa{sv}as",
|
|
(grd.UNIT_IFACE, {}, []),
|
|
)
|
|
new = new_signal(
|
|
DBusAddress(grd.MANAGER_PATH, interface=grd.MANAGER_IFACE),
|
|
"UnitNew",
|
|
"so",
|
|
(RAT, RAT_PATH),
|
|
)
|
|
queue = conn.queues[0][1]
|
|
queue.extend([stale, other, new])
|
|
bus.discard_pending(RAT_PATH)
|
|
assert list(queue) == [other, new]
|