| import sys
|
| import os
|
| import numpy as np
|
| import pandas as pd
|
| from PyQt6.QtWidgets import QApplication
|
| from PyQt6.QtCore import QTimer
|
| import pyqtgraph as pg
|
|
|
|
|
| sys.path.append(os.getcwd())
|
|
|
| from src.ui.chart_widget import ChartWidget
|
|
|
| def verify_chart_render():
|
| app = QApplication(sys.argv)
|
| widget = ChartWidget()
|
| widget.resize(800, 600)
|
| widget.show()
|
|
|
| print("Widget shown. Generating dummy data...")
|
|
|
|
|
| now = pd.Timestamp.now()
|
| dates = pd.date_range(start=now, periods=100, freq='1s')
|
| bids = np.linspace(100, 105, 100) + np.random.normal(0, 0.1, 100)
|
| asks = bids + 0.2
|
|
|
| df = pd.DataFrame({
|
| 'datetime': dates,
|
| 'bid': bids,
|
| 'ask': asks
|
| })
|
|
|
|
|
| widget.update_ticks(df)
|
| print("Ticks updated.")
|
|
|
|
|
| x, y = widget.bid_curve.getData()
|
| if x is not None and len(x) == 100:
|
| print("PASS: Bid curve has data.")
|
| else:
|
| print(f"FAIL: Bid curve data mismatch. Len: {len(x) if x is not None else 0}")
|
|
|
|
|
|
|
| level_times = [dates[i].timestamp() for i in range(0, 100, 10)]
|
| level_vah = np.linspace(101, 104, 10)
|
| level_val = np.linspace(99, 102, 10)
|
| level_poc = np.linspace(100, 103, 10)
|
|
|
| widget.update_levels(level_times, level_vah, level_val, level_poc)
|
| print("Levels updated.")
|
|
|
| x_vah, y_vah = widget.curve_vah.getData()
|
| if x_vah is not None and len(x_vah) == 10:
|
| print("PASS: VAH curve has data.")
|
| else:
|
| print(f"FAIL: VAH curve data mismatch. Len: {len(x_vah) if x_vah is not None else 0}")
|
|
|
|
|
|
|
|
|
|
|
| app.quit()
|
| print("Test finished.")
|
|
|
| if __name__ == "__main__":
|
| verify_chart_render()
|
|
|