Process Manager monitor app (Python): MonitorWidget filter+selection, live /proc list, Terminate/Kill/Refresh
This commit is contained in:
1 parent
03065d35bf
commit
e1da839538
5 files changed
+394
No files matched your search
@@ -413,3 +413,49 @@ class PropsTests(unittest.TestCase):
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
|
||||
class ProcessListFilterSelectionTests(unittest.TestCase):
|
||||
"""Filter + row selection added for the Process Manager app."""
|
||||
|
||||
def _procs(self):
|
||||
procs = core.create("XProcessList", "XProcessList_001")
|
||||
procs.set_rows([
|
||||
{"pid": 9, "name": "btop", "user": "root", "mem_kb": 10,
|
||||
"cpu": 1.0},
|
||||
{"pid": 3, "name": "alpha", "user": "root", "mem_kb": 20,
|
||||
"cpu": 9.0},
|
||||
{"pid": 5, "name": "beta", "user": "root", "mem_kb": 30,
|
||||
"cpu": 5.0},
|
||||
])
|
||||
return procs
|
||||
|
||||
def test_filter_by_name_and_pid(self):
|
||||
procs = self._procs()
|
||||
procs.set_filter("alp")
|
||||
self.assertEqual([r["pid"] for r in procs._sorted_rows()], [3])
|
||||
procs.set_filter("9")
|
||||
self.assertEqual([r["pid"] for r in procs._sorted_rows()], [9])
|
||||
procs.set_filter("")
|
||||
self.assertEqual(len(procs._sorted_rows()), 3)
|
||||
|
||||
def test_select_at_body_row_and_header_sort(self):
|
||||
procs = self._procs()
|
||||
# Default sort is CPU desc: alpha(9), beta(5), btop(1).
|
||||
# Body click on the first row (y=40 is row 0) selects pid 3.
|
||||
self.assertTrue(procs.select_at(100, 40))
|
||||
self.assertEqual(procs.selected_pid(), 3)
|
||||
# Header click on the PID column sorts by pid ascending.
|
||||
self.assertTrue(procs.select_at(10, 30))
|
||||
self.assertEqual([r["pid"] for r in procs._sorted_rows()],
|
||||
[3, 5, 9])
|
||||
# Selection survives the re-sort (stored as a pid).
|
||||
self.assertEqual(procs.selected_pid(), 3)
|
||||
|
||||
def test_selected_pid_none_when_row_gone(self):
|
||||
procs = self._procs()
|
||||
procs.select_at(100, 40)
|
||||
self.assertEqual(procs.selected_pid(), 3)
|
||||
procs.set_rows([{"pid": 9, "name": "btop", "user": "root",
|
||||
"mem_kb": 10, "cpu": 1.0}])
|
||||
self.assertIsNone(procs.selected_pid())
|
||||
Reference in new issue
Block a user