Local changes: Updated model training, removed debug instrumentation, and configuration improvements
This commit is contained in:
2
tests/utils/__init__.py
Normal file
2
tests/utils/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
"""Test utilities."""
|
||||
|
||||
26
tests/utils/helpers.py
Normal file
26
tests/utils/helpers.py
Normal file
@@ -0,0 +1,26 @@
|
||||
"""Test helper functions."""
|
||||
|
||||
import pandas as pd
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
||||
def create_sample_ohlcv(periods: int = 100) -> pd.DataFrame:
|
||||
"""Create sample OHLCV data."""
|
||||
dates = pd.date_range(start=datetime.now() - timedelta(hours=periods), periods=periods, freq='1H')
|
||||
return pd.DataFrame({
|
||||
'timestamp': dates,
|
||||
'open': [100 + i * 0.1 for i in range(periods)],
|
||||
'high': [101 + i * 0.1 for i in range(periods)],
|
||||
'low': [99 + i * 0.1 for i in range(periods)],
|
||||
'close': [100.5 + i * 0.1 for i in range(periods)],
|
||||
'volume': [1000.0] * periods
|
||||
})
|
||||
|
||||
|
||||
def assert_decimal_equal(actual, expected, places=2):
|
||||
"""Assert two decimals are equal within places."""
|
||||
from decimal import Decimal
|
||||
actual_decimal = Decimal(str(actual)).quantize(Decimal('0.01'))
|
||||
expected_decimal = Decimal(str(expected)).quantize(Decimal('0.01'))
|
||||
assert actual_decimal == expected_decimal
|
||||
|
||||
60
tests/utils/ui_helpers.py
Normal file
60
tests/utils/ui_helpers.py
Normal file
@@ -0,0 +1,60 @@
|
||||
"""UI testing utilities and helpers."""
|
||||
|
||||
from PyQt6.QtWidgets import QApplication
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def get_or_create_qapplication() -> QApplication:
|
||||
"""Get existing QApplication or create new one.
|
||||
|
||||
Returns:
|
||||
QApplication instance
|
||||
"""
|
||||
app = QApplication.instance()
|
||||
if app is None:
|
||||
app = QApplication([])
|
||||
return app
|
||||
|
||||
|
||||
def create_test_widget(widget_class, *args, **kwargs):
|
||||
"""Create widget instance for testing.
|
||||
|
||||
Args:
|
||||
widget_class: Widget class to instantiate
|
||||
*args: Positional arguments for widget
|
||||
**kwargs: Keyword arguments for widget
|
||||
|
||||
Returns:
|
||||
Widget instance
|
||||
"""
|
||||
app = get_or_create_qapplication()
|
||||
return widget_class(*args, **kwargs)
|
||||
|
||||
|
||||
class SignalSpy:
|
||||
"""Helper to spy on Qt signals."""
|
||||
|
||||
def __init__(self, signal):
|
||||
"""Initialize signal spy.
|
||||
|
||||
Args:
|
||||
signal: Qt signal to spy on
|
||||
"""
|
||||
self.signal = signal
|
||||
self.calls = []
|
||||
signal.connect(self._on_signal)
|
||||
|
||||
def _on_signal(self, *args, **kwargs):
|
||||
"""Record signal emission."""
|
||||
self.calls.append((args, kwargs))
|
||||
|
||||
def assert_called(self, times: Optional[int] = None):
|
||||
"""Assert signal was called.
|
||||
|
||||
Args:
|
||||
times: Expected number of calls (None for any)
|
||||
"""
|
||||
if times is None:
|
||||
assert len(self.calls) > 0, "Signal was not called"
|
||||
else:
|
||||
assert len(self.calls) == times, f"Signal called {len(self.calls)} times, expected {times}"
|
||||
Reference in New Issue
Block a user