def test_tab_navigation(self, mock_vsplit, mock_hsplit, mock_box, moc_cc, moc_fc, mock_layout): tab2 = CommandTab("command_2", None, None, None, MagicMock(), False) self.app.command_tabs["command_2"] = tab2 tab1 = self.app.command_tabs[self.command_name] self.app.handle_tab_command(self.mock_hb, self.command_name, {"close": False}) self.app.handle_tab_command(self.mock_hb, "command_2", {"close": False}) self.assertTrue(tab2.is_selected) self.app.tab_navigate_left() self.assertTrue(tab1.is_selected) self.assertFalse(tab2.is_selected) self.app.tab_navigate_left() self.assertTrue(all(not t.is_selected for t in self.app.command_tabs.values())) self.app.tab_navigate_left() self.assertTrue(all(not t.is_selected for t in self.app.command_tabs.values())) self.app.tab_navigate_right() self.assertTrue(tab1.is_selected) self.app.tab_navigate_right() self.assertFalse(tab1.is_selected) self.assertTrue(tab2.is_selected) self.app.tab_navigate_right() self.assertFalse(tab1.is_selected) self.assertTrue(tab2.is_selected)
def setUp(self) -> None: super().setUp() tabs = {self.command_name: CommandTab(self.command_name, None, None, None, MagicMock())} self.mock_hb = MagicMock() self.app = HummingbotCLI(None, None, None, tabs) self.app.app = MagicMock()
def init_command_tabs(self) -> Dict[str, CommandTab]: """ Initiates and returns a CommandTab dictionary with mostly defaults and None values, These values will be populated later on by HummingbotCLI """ command_tabs: Dict[str, CommandTab] = {} for tab_class in tab_classes: name = tab_class.get_command_name() command_tabs[name] = CommandTab(name, None, None, None, tab_class) return command_tabs
def display_tab_output(self, command_tab: CommandTab, hummingbot: "HummingbotApplication", kwargs: Dict[Any, Any]): if command_tab.task is not None and not command_tab.task.done(): return if threading.current_thread() != threading.main_thread(): hummingbot.ev_loop.call_soon_threadsafe(self.display_tab_output, command_tab, hummingbot, kwargs) return command_tab.task = safe_ensure_future(command_tab.tab_class.display(command_tab.output_field, hummingbot, **kwargs))
def setUp(self) -> None: super().setUp() self.client_config_map = ClientConfigAdapter(ClientConfigMap()) tabs = { self.command_name: CommandTab(self.command_name, None, None, None, MagicMock()) } self.mock_hb = MagicMock() self.app = HummingbotCLI(client_config_map=self.client_config_map, input_handler=None, bindings=None, completer=None, command_tabs=tabs) self.app.app = MagicMock() self.hb = HummingbotApplication()