MCPcopy
hub / github.com/tanelpoder/0xtools / XtopTUIWrapper

Class XtopTUIWrapper

xtop/tests/test_tui_basic.py:35–75  ·  view source on GitHub ↗

Wrapper to make xtop-tui testable

Source from the content-addressed store, hash-verified

33import importlib.util
34
35class XtopTUIWrapper:
36 """Wrapper to make xtop-tui testable"""
37 def __init__(self, datadir: str,
38 low_time=None, high_time=None, initial_group_cols=None):
39 # Load the TUI module dynamically
40 spec = importlib.util.spec_from_file_location(
41 "xtop_tui",
42 Path(__file__).parent.parent / "xtop-tui.py"
43 )
44 module = importlib.util.module_from_spec(spec)
45
46 # Set the module's __path__ to help with relative imports
47 module.__file__ = str(Path(__file__).parent.parent / "xtop-tui.py")
48
49 # Execute the module
50 spec.loader.exec_module(module)
51
52 self.app_class = module.XTopTUI
53 self.datadir = datadir
54 # Removed initial_query_type - always dynamic now
55 self.low_time = low_time
56 self.high_time = high_time
57 self.initial_group_cols = initial_group_cols or ['state'] # Default to just 'state'
58
59 def create_app(self):
60 """Create an instance of the app"""
61 # Override the default grouping to just 'state' for tests
62 original_defaults = QueryEngine.DEFAULT_GROUP_COLS.copy()
63 for key in original_defaults:
64 QueryEngine.DEFAULT_GROUP_COLS[key] = self.initial_group_cols
65
66 app = self.app_class(
67 datadir=self.datadir,
68 low_time=self.low_time,
69 high_time=self.high_time
70 )
71
72 # Restore original defaults after creating app
73 QueryEngine.DEFAULT_GROUP_COLS = original_defaults
74
75 return app
76
77
78# Helper functions for navigation

Callers 8

test_cli_mappingFunction · 0.90
test_tui_startupFunction · 0.70
test_grouping_menuFunction · 0.70
test_add_single_columnFunction · 0.70
test_latency_columnsFunction · 0.70
test_peek_functionalityFunction · 0.70
test_navigation_keysFunction · 0.70

Calls

no outgoing calls

Tested by 8

test_cli_mappingFunction · 0.72
test_tui_startupFunction · 0.56
test_grouping_menuFunction · 0.56
test_add_single_columnFunction · 0.56
test_latency_columnsFunction · 0.56
test_peek_functionalityFunction · 0.56
test_navigation_keysFunction · 0.56