refactor: use tabs for selected instrument tables
This commit is contained in:
@@ -38,7 +38,7 @@ def test_main_window_can_be_constructed_offscreen(tmp_path, monkeypatch):
|
||||
def test_main_window_contains_grid_level_table(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
from PySide6.QtWidgets import QApplication, QGroupBox
|
||||
from PySide6.QtWidgets import QApplication, QTabWidget
|
||||
|
||||
from grid_trading.services.trading_service import TradingService
|
||||
from grid_trading.ui.main_window import MainWindow
|
||||
@@ -48,7 +48,9 @@ def test_main_window_contains_grid_level_table(tmp_path, monkeypatch):
|
||||
window = MainWindow(service)
|
||||
|
||||
assert window.grid_levels_table.columnCount() == 7
|
||||
assert any(group.title() == "网格档位" for group in window.findChildren(QGroupBox))
|
||||
tab_titles = _tab_titles(window.details_tabs)
|
||||
assert tab_titles == ["网格档位", "待卖网格", "最近成交"]
|
||||
assert isinstance(window.details_tabs, QTabWidget)
|
||||
|
||||
window.close()
|
||||
service.close()
|
||||
@@ -58,6 +60,26 @@ def test_main_window_contains_grid_level_table(tmp_path, monkeypatch):
|
||||
def test_main_window_contains_open_grid_lots_table(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from grid_trading.services.trading_service import TradingService
|
||||
from grid_trading.ui.main_window import MainWindow
|
||||
|
||||
app = QApplication.instance() or QApplication([])
|
||||
service = TradingService(tmp_path / "grid.db")
|
||||
window = MainWindow(service)
|
||||
|
||||
assert window.open_grid_lots_table.columnCount() == 8
|
||||
assert "待卖网格" in _tab_titles(window.details_tabs)
|
||||
|
||||
window.close()
|
||||
service.close()
|
||||
app.processEvents()
|
||||
|
||||
|
||||
def test_main_window_removes_selected_instrument_detail_group(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
from PySide6.QtWidgets import QApplication, QGroupBox
|
||||
|
||||
from grid_trading.services.trading_service import TradingService
|
||||
@@ -67,8 +89,7 @@ def test_main_window_contains_open_grid_lots_table(tmp_path, monkeypatch):
|
||||
service = TradingService(tmp_path / "grid.db")
|
||||
window = MainWindow(service)
|
||||
|
||||
assert window.open_grid_lots_table.columnCount() == 8
|
||||
assert any(group.title() == "待卖网格" for group in window.findChildren(QGroupBox))
|
||||
assert not any(group.title() == "选中标的详情" for group in window.findChildren(QGroupBox))
|
||||
|
||||
window.close()
|
||||
service.close()
|
||||
@@ -116,6 +137,10 @@ def test_trade_dialog_labels_price_as_trade_price(tmp_path, monkeypatch):
|
||||
app.processEvents()
|
||||
|
||||
|
||||
def _tab_titles(tabs):
|
||||
return [tabs.tabText(index) for index in range(tabs.count())]
|
||||
|
||||
|
||||
def test_quote_refresh_does_not_block_main_window(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user