summaryrefslogtreecommitdiff
path: root/shared/tests/test_models.py
diff options
context:
space:
mode:
Diffstat (limited to 'shared/tests/test_models.py')
-rw-r--r--shared/tests/test_models.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/shared/tests/test_models.py b/shared/tests/test_models.py
index f1d92ec..25ab4c9 100644
--- a/shared/tests/test_models.py
+++ b/shared/tests/test_models.py
@@ -1,6 +1,6 @@
"""Tests for shared models and settings."""
+
import os
-import pytest
from decimal import Decimal
from datetime import datetime, timezone
from unittest.mock import patch
@@ -8,11 +8,15 @@ from unittest.mock import patch
def test_settings_defaults():
"""Test that Settings has correct defaults."""
- with patch.dict(os.environ, {
- "BINANCE_API_KEY": "test_key",
- "BINANCE_API_SECRET": "test_secret",
- }):
+ with patch.dict(
+ os.environ,
+ {
+ "BINANCE_API_KEY": "test_key",
+ "BINANCE_API_SECRET": "test_secret",
+ },
+ ):
from shared.config import Settings
+
settings = Settings()
assert settings.redis_url == "redis://localhost:6379"
assert settings.database_url == "postgresql://trading:trading@localhost:5432/trading"
@@ -26,6 +30,7 @@ def test_settings_defaults():
def test_candle_creation():
"""Test Candle model creation."""
from shared.models import Candle
+
now = datetime.now(timezone.utc)
candle = Candle(
symbol="BTCUSDT",
@@ -49,6 +54,7 @@ def test_candle_creation():
def test_signal_creation():
"""Test Signal model creation."""
from shared.models import Signal, OrderSide
+
signal = Signal(
strategy="rsi_strategy",
symbol="BTCUSDT",
@@ -71,6 +77,7 @@ def test_order_creation():
"""Test Order model creation with defaults."""
from shared.models import Order, OrderSide, OrderType, OrderStatus
import uuid
+
signal_id = str(uuid.uuid4())
order = Order(
signal_id=signal_id,
@@ -90,6 +97,7 @@ def test_order_creation():
def test_position_unrealized_pnl():
"""Test Position unrealized_pnl computed property."""
from shared.models import Position
+
position = Position(
symbol="BTCUSDT",
quantity=Decimal("0.1"),