bumblebee-status/tests/util/test_cli.py

34 lines
709 B
Python
Raw Permalink Normal View History

2020-06-20 14:53:44 +02:00
import pytest
import util.cli
2020-06-20 15:11:53 +02:00
2020-06-20 14:53:44 +02:00
def test_valid_command():
assert util.cli.execute("echo test") == "test\n"
2020-06-20 15:11:53 +02:00
2020-06-20 14:53:44 +02:00
def test_utf_command():
rv = util.cli.execute("echo ÖPmŧß")
assert util.cli.execute("echo ÖPmŧß") == "ÖPmŧß\n"
2020-06-20 15:11:53 +02:00
2020-06-20 14:53:44 +02:00
def test_invalid_command():
with pytest.raises(RuntimeError):
util.cli.execute("i-do-not-exist")
2020-06-20 15:11:53 +02:00
2020-06-20 14:53:44 +02:00
def test_command_exit_code():
with pytest.raises(RuntimeError):
util.cli.execute("cat i-do-not-exist")
2020-06-20 15:11:53 +02:00
2020-06-20 14:53:44 +02:00
def test_command_exit_code_no_error():
util.cli.execute("cat i-do-not-exist", ignore_errors=True)
2020-06-20 15:11:53 +02:00
2020-06-20 14:53:44 +02:00
def test_async():
assert util.cli.execute("echo test", wait=False) == ""
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4