added adaptive quickshell
This commit is contained in:
1 parent
6eb56d2065
commit
5b33a73fd8
189 files changed
+8678
-15
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
path = Path(__file__).resolve().parents[1] / 'backend' / 'power_profiles.py'
|
||||
spec = importlib.util.spec_from_file_location('power_profiles', path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
|
||||
def test_get():
|
||||
def runner(args, **kwargs):
|
||||
assert args == ['powerprofilesctl', 'get']
|
||||
return SimpleNamespace(returncode=0, stdout='balanced\n', stderr='')
|
||||
assert module.execute(['get'], runner=runner, which=lambda _: '/bin/powerprofilesctl')['profile'] == 'balanced'
|
||||
|
||||
|
||||
def test_invalid_profile_never_invokes_command():
|
||||
def runner(*args, **kwargs):
|
||||
raise AssertionError('must not run')
|
||||
assert not module.execute(['set', ';reboot'], runner=runner, which=lambda _: '/bin/powerprofilesctl')['ok']
|
||||
|
||||
|
||||
def test_missing_utility():
|
||||
assert not module.execute(['get'], which=lambda _: None)['ok']
|
||||
|
||||
|
||||
def test_backend_failure():
|
||||
def runner(args, **kwargs):
|
||||
return SimpleNamespace(returncode=1, stdout='', stderr='denied')
|
||||
assert 'denied' in module.execute(['set', 'balanced'], runner=runner, which=lambda _: '/bin/powerprofilesctl')['error']
|
||||
Reference in new issue
Block a user