File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed
Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change 1+ import pytest
2+ import pandas as pd
3+ import sys
4+ from pathlib import Path
5+
6+ # Add src to path so we can import the modules
7+ sys .path .append (str (Path (__file__ ).parent .parent / 'src' ))
8+
9+ from financial_model import FinancialModel
10+
11+ @pytest .fixture
12+ def model ():
13+ """Fixture to create a fresh model instance for each test"""
14+ return FinancialModel ()
15+
16+ def test_user_growth_projection (model ):
17+ """Test that user growth projection returns valid data"""
18+ months = 12
19+ df = model .project_user_growth (months = months )
20+
21+ # Assertions
22+ assert isinstance (df , pd .DataFrame )
23+ assert len (df ) == months
24+ assert 'total_users' in df .columns
25+ assert 'mrr' in df .columns
26+ assert df ['total_users' ].iloc [- 1 ] > 0 # Users should grow
27+
28+ def test_break_even_calculation (model ):
29+ """Test break-even analysis"""
30+ # First ensure we have projections
31+ model .project_user_growth (months = 24 )
32+
33+ breakeven = model .calculate_break_even ()
34+
35+ assert isinstance (breakeven , dict )
36+ assert 'month' in breakeven
37+ assert 'is_reached' in breakeven
Original file line number Diff line number Diff line change 1+ import pytest
2+ import sys
3+ from pathlib import Path
4+
5+ # Add src to path
6+ sys .path .append (str (Path (__file__ ).parent .parent / 'src' ))
7+
8+ from market_sizer import MarketSizer
9+
10+ @pytest .fixture
11+ def sizer ():
12+ return MarketSizer ()
13+
14+ def test_tam_calculation (sizer ):
15+ """Test Total Addressable Market calculation"""
16+ tam = sizer .calculate_tam ()
17+
18+ assert isinstance (tam , dict )
19+ assert 'total_users' in tam
20+ assert 'annual_value' in tam
21+ assert tam ['total_users' ] > 0
22+
23+ def test_som_calculation (sizer ):
24+ """Test Serviceable Obtainable Market calculation"""
25+ # SOM depends on TAM and SAM, so we run them all
26+ sizer .calculate_tam ()
27+ sizer .calculate_sam ()
28+ som = sizer .calculate_som ()
29+
30+ assert isinstance (som , dict )
31+ assert 'final' in som
32+ assert som ['final' ] > 0
33+ # SOM should be smaller than TAM
34+ assert som ['final' ] < sizer .tam_data ['total_users' ]
You can’t perform that action at this time.
0 commit comments