|
| 1 | +from datetime import datetime |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from src.penn_chime.parameters import ( |
| 6 | + Parameters, |
| 7 | + Disposition, |
| 8 | + Regions, |
| 9 | +) |
| 10 | +from src.penn_chime.models import SimSirModel |
| 11 | + |
| 12 | + |
| 13 | +class MockStreamlit: |
| 14 | + def __init__(self): |
| 15 | + self.render_store = [] |
| 16 | + self.markdown = self.just_store_instead_of_rendering |
| 17 | + self.latex = self.just_store_instead_of_rendering |
| 18 | + self.subheader = self.just_store_instead_of_rendering |
| 19 | + |
| 20 | + def just_store_instead_of_rendering(self, inp, *args, **kwargs): |
| 21 | + self.render_store.append(inp) |
| 22 | + return None |
| 23 | + |
| 24 | + |
| 25 | +@pytest.fixture |
| 26 | +def mock_st(): |
| 27 | + return MockStreamlit() |
| 28 | + |
| 29 | + |
| 30 | +# The defaults in settings will change and break the tests |
| 31 | +@pytest.fixture |
| 32 | +def DEFAULTS(): |
| 33 | + return Parameters( |
| 34 | + region=Regions( |
| 35 | + delaware=564696, |
| 36 | + chester=519293, |
| 37 | + montgomery=826075, |
| 38 | + bucks=628341, |
| 39 | + philly=1581000, |
| 40 | + ), |
| 41 | + current_date=datetime(year=2020, month=3, day=28), |
| 42 | + current_hospitalized=14, |
| 43 | + date_first_hospitalized=datetime(year=2020, month=3, day=7), |
| 44 | + doubling_time=4.0, |
| 45 | + n_days=60, |
| 46 | + market_share=0.15, |
| 47 | + relative_contact_rate=0.3, |
| 48 | + hospitalized=Disposition(0.025, 7), |
| 49 | + icu=Disposition(0.0075, 9), |
| 50 | + ventilated=Disposition(0.005, 10), |
| 51 | + ) |
| 52 | + |
| 53 | + |
| 54 | +@pytest.fixture |
| 55 | +def param(): |
| 56 | + return Parameters( |
| 57 | + current_date=datetime(year=2020, month=3, day=28), |
| 58 | + current_hospitalized=100, |
| 59 | + doubling_time=6.0, |
| 60 | + market_share=0.05, |
| 61 | + relative_contact_rate=0.15, |
| 62 | + population=500000, |
| 63 | + hospitalized=Disposition(0.05, 7), |
| 64 | + icu=Disposition(0.02, 9), |
| 65 | + ventilated=Disposition(0.01, 10), |
| 66 | + n_days=60, |
| 67 | + ) |
| 68 | + |
| 69 | + |
| 70 | +@pytest.fixture |
| 71 | +def halving_param(): |
| 72 | + return Parameters( |
| 73 | + current_date=datetime(year=2020, month=3, day=28), |
| 74 | + current_hospitalized=100, |
| 75 | + doubling_time=6.0, |
| 76 | + market_share=0.05, |
| 77 | + relative_contact_rate=0.7, |
| 78 | + population=500000, |
| 79 | + hospitalized=Disposition(0.05, 7), |
| 80 | + icu=Disposition(0.02, 9), |
| 81 | + ventilated=Disposition(0.01, 10), |
| 82 | + n_days=60, |
| 83 | + ) |
| 84 | + |
| 85 | + |
| 86 | +@pytest.fixture |
| 87 | +def model(param): |
| 88 | + return SimSirModel(param) |
| 89 | + |
| 90 | + |
| 91 | +@pytest.fixture |
| 92 | +def halving_model(halving_param): |
| 93 | + return SimSirModel(halving_param) |
0 commit comments