fix: separate trade price from realtime price

This commit is contained in:
王鹏
2026-07-09 10:45:27 +08:00
parent 5bbc4e607a
commit 15636fb910
9 changed files with 105 additions and 55 deletions

View File

@@ -35,6 +35,47 @@ def test_main_window_can_be_constructed_offscreen(tmp_path, monkeypatch):
app.processEvents()
def test_instrument_dialog_does_not_collect_manual_current_price(monkeypatch):
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
from PySide6.QtWidgets import QApplication, QLabel
from grid_trading.ui.dialogs import InstrumentDialog
app = QApplication.instance() or QApplication([])
dialog = InstrumentDialog()
labels = [label.text() for label in dialog.findChildren(QLabel)]
assert "手动价格" not in labels
assert not hasattr(dialog, "manual_price_edit")
assert dialog.to_instrument().manual_price is None
dialog.close()
app.processEvents()
def test_trade_dialog_labels_price_as_trade_price(tmp_path, monkeypatch):
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")
from PySide6.QtWidgets import QApplication, QLabel
from grid_trading.services.trading_service import TradingService
from grid_trading.ui.dialogs import TradeDialog
app = QApplication.instance() or QApplication([])
service = TradingService(tmp_path / "grid.db")
service.ensure_defaults()
account = service.get_active_account()
dialog = TradeDialog(service, account.id, [Instrument(id=1, code="510300", name="沪深300ETF")])
labels = [label.text() for label in dialog.findChildren(QLabel)]
assert "成交价" in labels
dialog.close()
service.close()
app.processEvents()
def test_quote_refresh_does_not_block_main_window(tmp_path, monkeypatch):
monkeypatch.setenv("QT_QPA_PLATFORM", "offscreen")