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
Exemple #2
0
 def test_get_applicable_deals_returns_list_with_1_deal(self):
     event = Event('flood', 'Louisiana', 500, deals)
     event.deals_list = []
     event.get_applicable_deals(deals)
     self.assertAlmostEqual(event.deals_list,
                            [{
                                'retention': 250,
                                'limit': 250,
                                'perils': ['hurricane', 'flood'],
                                'regions': ['Florida', 'Louisiana']
                            }])
Exemple #3
0
 def test_get_applicable_deals_returns_list_with_2_deal(self):
     event = Event('hurricane', 'Florida', 2000, deals)
     event.deals_list = []
     event.get_applicable_deals(deals)
     self._baseAssertEqual(event.deals_list,
                           [{
                               'regions': ['Florida', 'Louisiana'],
                               'perils': ['hurricane', 'flood'],
                               'limit': 250,
                               'retention': 250
                           }, {
                               'regions': ['Florida'],
                               'perils': ['hurricane'],
                               'limit': 3000,
                               'retention': 1000
                           }])
Exemple #4
0
 def test_get_applicable_deals_returns_empty_list_when_there_is_no_deal_for_event(
         self):
     event = Event('hurricane', 'Minnesota', 2000, deals)
     event.deals_list = ['dummy data']
     event.get_applicable_deals(deals)
     self._baseAssertEqual(event.deals_list, [])