Add a basic test suit

This commit is contained in:
Tony Crisci
2019-04-30 22:40:31 -04:00
parent 2330b64ff9
commit 8907df2394
12 changed files with 439 additions and 0 deletions

23
test/test_commands.py Normal file
View 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}'