Sanchit7 commited on
Commit
b7cd68f
·
1 Parent(s): 816a68f

Add missing src/models directory and tests

Browse files
Files changed (3) hide show
  1. tests/__init__.py +1 -0
  2. tests/conftest.py +32 -0
  3. tests/test_basic.py +57 -0
tests/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """Test suite for Financial Research Agent"""
tests/conftest.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Pytest configuration and fixtures"""
2
+
3
+ import pytest
4
+ import asyncio
5
+
6
+
7
+ @pytest.fixture(scope="session")
8
+ def event_loop():
9
+ """Create an event loop for async tests"""
10
+ loop = asyncio.get_event_loop_policy().new_event_loop()
11
+ yield loop
12
+ loop.close()
13
+
14
+
15
+ @pytest.fixture
16
+ def sample_ticker():
17
+ """Sample ticker for testing"""
18
+ return "TSLA"
19
+
20
+
21
+ @pytest.fixture
22
+ def sample_analysis_request():
23
+ """Sample analysis request"""
24
+ from src.core.types import AnalysisRequest
25
+
26
+ return AnalysisRequest(
27
+ ticker="TSLA",
28
+ company_name="Tesla Inc",
29
+ filing_type="10-K",
30
+ include_news=False, # Skip news for faster tests
31
+ include_technicals=False, # Skip technicals for faster tests
32
+ )
tests/test_basic.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Basic sanity tests"""
2
+
3
+ import pytest
4
+ from src.core.config import config
5
+ from src.core.types import AnalysisRequest, SentimentScore
6
+
7
+
8
+ def test_config_loads():
9
+ """Test that configuration loads properly"""
10
+ assert config is not None
11
+ assert config.model is not None
12
+ assert config.sec is not None
13
+
14
+
15
+ def test_analysis_request_creation():
16
+ """Test creating an analysis request"""
17
+ request = AnalysisRequest(
18
+ ticker="TSLA",
19
+ company_name="Tesla Inc",
20
+ filing_type="10-K",
21
+ )
22
+
23
+ assert request.ticker == "TSLA"
24
+ assert request.company_name == "Tesla Inc"
25
+ assert request.filing_type == "10-K"
26
+ assert request.include_news is True # default
27
+
28
+
29
+ def test_sentiment_score():
30
+ """Test sentiment score calculations"""
31
+ sentiment = SentimentScore(positive=0.7, negative=0.2, neutral=0.1)
32
+
33
+ assert sentiment.dominant == "positive"
34
+ assert sentiment.confidence == 0.7
35
+ assert 0 <= sentiment.positive <= 1
36
+ assert 0 <= sentiment.negative <= 1
37
+ assert 0 <= sentiment.neutral <= 1
38
+
39
+
40
+ def test_sentiment_score_neutral():
41
+ """Test neutral sentiment"""
42
+ sentiment = SentimentScore(positive=0.3, negative=0.3, neutral=0.4)
43
+ assert sentiment.dominant == "neutral"
44
+
45
+
46
+ @pytest.mark.parametrize(
47
+ "ticker,expected",
48
+ [
49
+ ("TSLA", "TSLA"),
50
+ ("aapl", "aapl"),
51
+ ("RBLX", "RBLX"),
52
+ ],
53
+ )
54
+ def test_ticker_handling(ticker, expected):
55
+ """Test different ticker formats"""
56
+ request = AnalysisRequest(ticker=ticker)
57
+ assert request.ticker == expected