Add a basic test suit
This commit is contained in:
23
test/test_commands.py
Normal file
23
test/test_commands.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from .mpris import setup_buses, get_interfaces
|
||||
from .playerctl import playerctl
|
||||
|
||||
import asyncio
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_commands():
|
||||
[bus] = await setup_buses('commands')
|
||||
[interface] = get_interfaces(bus)
|
||||
|
||||
commands = ('play', 'pause', 'play-pause', 'stop', 'next', 'previous')
|
||||
|
||||
def get_called(cmd):
|
||||
return getattr(interface, f'{cmd.replace("-", "_")}_called')
|
||||
|
||||
results = await asyncio.gather(*(playerctl(f'-p commands {cmd}')
|
||||
for cmd in commands))
|
||||
|
||||
for i, result in enumerate(results):
|
||||
cmd = commands[i]
|
||||
assert get_called(cmd), f'{cmd} was not called: {result.stderr}'
|
Reference in New Issue
Block a user