def test_add_new_region_to_existing_deal_and_calculate_loss(self): """ Tests that a new region can be added dynamically to an existing deal for an uncovered event and the loss can be calculated on the fly """ peril = 'fire' region = 'Porto' damage = 400 event = Event(peril, region, damage, deals) if not event.deals_list: ManageDeals.add_new_deal(250, 250, [ peril, ], [ region, ], deals) peril = 'fire' region = 'Lisbon' damage = 700 event = Event(peril, region, damage, deals) if not event.deals_list: ManageDeals.add_region_to_deal('deal4', region, deals) event.get_applicable_deals(deals) loss = event.total_loss() assert loss == 250
def test_calculate_loss_event3(self): """ Tests that event3 causes a loss of 250 """ event = Event('flood', 'Florida', 750, deals) loss = event.total_loss() assert loss == 250
def test_calculate_loss_event1(self): """ Tests that event1 causes a loss of 500 """ event = Event('earthquake', 'California', 1000, deals) loss = event.total_loss() assert loss == 500
def test_calculate_loss_event4(self): """ Tests that event4 causes a loss of 1250. Tests when an event affects more than 1 deal. """ event = Event('hurricane', 'Florida', 2000, deals) loss = event.total_loss() assert loss == 1250
def test_calculate_loss_event2(self): """ Tests that event2 causes a loss of 250 """ event = Event('flood', 'Louisiana', 500, deals) loss = event.total_loss() assert loss == 250
def test_total_loss_limited_by_limit(self): event = Event('flood', 'Louisiana', 450000, deals) self.assertTrue(event.total_loss() == 250)
def test_total_loss_returns_0_with_several_deals_when_damage_lower_the_retetion( self): event = Event('hurricane', 'Florida', 50, deals) self.assertTrue(event.total_loss() == 0)
def test_total_loss_lower_then_limit(self): event = Event('flood', 'Louisiana', 450, deals) self.assertTrue(event.total_loss() == 200)
def test_total_loss_returns_0_when_damage_lower_then_retention(self): event = Event('flood', 'Louisiana', 100, deals) self.assertTrue(event.total_loss() == 0)
def test_total_loss_returns_0_when_no_deal_exists_for_event(self): event = Event('hurricane', 'Minnesota', 2000, deals) event.deals_list = [] self.assertTrue(event.total_loss() == 0)
def test_total_loss_when_damage_higher_then_deal3_limit_and_deal2_limit( self): event = Event('hurricane', 'Florida', 5000, deals) self.assertTrue(event.total_loss() == 3250)
def test_total_loss_returns_limit_from_1st_deal_when_damage_higher_then_limit( self): event = Event('hurricane', 'Florida', 600, deals) self.assertTrue(event.total_loss() == 250)