36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
|
|
"""Tests for CSV exporter."""
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
from pathlib import Path
|
||
|
|
from tempfile import TemporaryDirectory
|
||
|
|
from src.reporting.csv_exporter import get_csv_exporter, CSVExporter
|
||
|
|
|
||
|
|
|
||
|
|
class TestCSVExporter:
|
||
|
|
"""Tests for CSVExporter."""
|
||
|
|
|
||
|
|
@pytest.fixture
|
||
|
|
def exporter(self):
|
||
|
|
"""Create CSV exporter instance."""
|
||
|
|
return get_csv_exporter()
|
||
|
|
|
||
|
|
def test_export_trades(self, exporter, mock_database):
|
||
|
|
"""Test exporting trades."""
|
||
|
|
engine, Session = mock_database
|
||
|
|
|
||
|
|
with TemporaryDirectory() as tmpdir:
|
||
|
|
filepath = Path(tmpdir) / "trades.csv"
|
||
|
|
|
||
|
|
# Export (may be empty if no trades)
|
||
|
|
result = exporter.export_trades(filepath, paper_trading=True)
|
||
|
|
assert isinstance(result, bool)
|
||
|
|
|
||
|
|
def test_export_portfolio(self, exporter):
|
||
|
|
"""Test exporting portfolio."""
|
||
|
|
with TemporaryDirectory() as tmpdir:
|
||
|
|
filepath = Path(tmpdir) / "portfolio.csv"
|
||
|
|
|
||
|
|
result = exporter.export_portfolio(filepath)
|
||
|
|
assert isinstance(result, bool)
|
||
|
|
|