1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
import unittest
import deckit.modules.windows as windows
class Commands(unittest.TestCase):
def test_lua_and_classic(self):
self.assertEqual(windows.workspace_cmd(3, lua=False),
["hyprctl", "dispatch", "workspace", "3"])
self.assertEqual(windows.workspace_cmd(3, lua=True)[:2], ["hyprctl", "eval"])
def test_address_guard(self):
self.assertIsNone(windows.ADDR.fullmatch("0x1;rm"))
self.assertTrue(windows.ADDR.fullmatch("0x55897e5c0800"))
def test_state_lists_all_workspaces(self):
responses = {
("hyprctl", "clients", "-j"): "[]",
("hyprctl", "activewindow", "-j"): "{}",
("hyprctl", "monitors", "-j"): "[]",
("hyprctl", "workspaces", "-j"): '[{"id": 1}, {"id": 2}, {"id": 5}]',
}
st = windows._state(lambda cmd: responses[tuple(cmd)])
self.assertEqual(st["workspaces"], [1, 2, 5])
def test_state_includes_empty_workspaces_and_launch_icons(self):
responses = {
("hyprctl", "clients", "-j"): "[]",
("hyprctl", "activewindow", "-j"): "{}",
("hyprctl", "workspaces", "-j"): '[{"id": 3}]',
}
m = windows.make({
"windows": {"workspaces": [1, 2, 3, 4]},
"launch": {"obs": {"icon": "obsstudio", "command": "obs"}},
"run": lambda cmd: responses[tuple(cmd)],
})
st = m.state()
self.assertEqual(st["workspaces"], [1, 2, 3, 4])
self.assertEqual(st["launches"], [{"key": "obs", "icon": "obsstudio", "label": "obs"}])
if __name__ == "__main__":
unittest.main()
|