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,27 @@
|
||||
import importlib.util
|
||||
from pathlib import Path
|
||||
from unittest import TestCase
|
||||
from unittest.mock import patch
|
||||
|
||||
path = Path(__file__).resolve().parents[1] / 'backend' / 'modem_control.py'
|
||||
spec = importlib.util.spec_from_file_location('modem_control', path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
|
||||
|
||||
class ModemControlTests(TestCase):
|
||||
def test_rejects_invalid_ids(self):
|
||||
for value in ('-1', '1;touch /tmp/foo', '../../etc/passwd', '999999'):
|
||||
self.assertFalse(module.control(value, 'enable')['ok'])
|
||||
|
||||
def test_rejects_arbitrary_actions(self):
|
||||
self.assertFalse(module.control('0', 'reset')['ok'])
|
||||
|
||||
@patch.object(module.shutil, 'which', return_value='/usr/bin/mmcli')
|
||||
def test_uses_argument_vector(self, _):
|
||||
calls = []
|
||||
def runner(args, **kwargs):
|
||||
calls.append(args)
|
||||
return type('Result', (), {'returncode': 0, 'stderr': ''})()
|
||||
self.assertTrue(module.control('7', 'disable', runner)['ok'])
|
||||
self.assertEqual(calls, [['mmcli', '-m', '7', '--disable']])
|
||||
Reference in new issue
Block a user