Ejemplo n.º 1
0
 def setUp(self):
     self.content = StringIO('expModId,assetCategory,description,stcoType,'
                             'stcoUnit,areaType,areaUnit,cocoType,'
                             'cocoUnit,recoType,recoUnit,taxonomySource\n'
                             'PAV01,buildings,Collection of existing '
                             'building in downtown Pavia,aggregated,USD,'
                             'per_asset,GBP,per_area,CHF,aggregated, '
                             'EUR,pavia taxonomy\n\n'
                             'lon,lat,taxonomy,stco,number,area,reco,coco,'
                             'occupantDay,occupantNight,deductible,limit\n'
                             '28.6925,40.9775,RC_MR_LC,40000,50,1500,4000,'
                             '1000,10,,0.05,32000\n'
                             '28.6975,40.9825,RC_MR_LC,300000,100,1000,'
                             '30000,2000,15,,0.10,240000')
     self.exp_reader = ExposureTxtReader(self.content)
Ejemplo n.º 2
0
 def setUp(self):
     self.content = StringIO('expModId,assetCategory,description,stcoType,'
                             'stcoUnit,areaType,areaUnit,cocoType,'
                             'cocoUnit,recoType,recoUnit,taxonomySource\n'
                             'PAV01,buildings,Collection of existing '
                             'building in downtown Pavia,aggregated,USD,'
                             'per_asset,GBP,per_area,CHF,aggregated, '
                             'EUR,pavia taxonomy\n\n'
                             'lon,lat,taxonomy,stco,number,area,reco,coco,'
                             'occupantDay,occupantNight,deductible,limit\n'
                             '28.6925,40.9775,RC_MR_LC,40000,50,1500,4000,'
                             '1000,10,,0.05,32000\n'
                             '28.6975,40.9825,RC_MR_LC,300000,100,1000,'
                             '30000,2000,15,,0.10,240000')
     self.exp_reader = ExposureTxtReader(self.content)
Ejemplo n.º 3
0
class AnExposureTxtReaderShould(unittest.TestCase):

    def setUp(self):
        self.content = StringIO('expModId,assetCategory,description,stcoType,'
                                'stcoUnit,areaType,areaUnit,cocoType,'
                                'cocoUnit,recoType,recoUnit,taxonomySource\n'
                                'PAV01,buildings,Collection of existing '
                                'building in downtown Pavia,aggregated,USD,'
                                'per_asset,GBP,per_area,CHF,aggregated, '
                                'EUR,pavia taxonomy\n\n'
                                'lon,lat,taxonomy,stco,number,area,reco,coco,'
                                'occupantDay,occupantNight,deductible,limit\n'
                                '28.6925,40.9775,RC_MR_LC,40000,50,1500,4000,'
                                '1000,10,,0.05,32000\n'
                                '28.6975,40.9825,RC_MR_LC,300000,100,1000,'
                                '30000,2000,15,,0.10,240000')
        self.exp_reader = ExposureTxtReader(self.content)

    def test_read_meta_data(self):
        desc = 'Collection of existing building in downtown Pavia'
        expected_meta_data = dict(
            expModId='PAV01', assetCategory='buildings', description=desc,
            stcoType='aggregated', stcoUnit='USD', areaType='per_asset',
            areaUnit='GBP', cocoType='per_area', cocoUnit='CHF',
            recoType='aggregated', recoUnit='EUR',
            taxonomySource='pavia taxonomy')

        self.assertEqual(expected_meta_data, self.exp_reader.metadata)

    def test_read_assets(self):
        first_asset = {'reco': '4000', 'area': '1500', 'taxonomy': 'RC_MR_LC',
                       'stco': '40000', 'lon': '28.6925', 'number': '50',
                       'coco': '1000', 'limit': '32000', 'lat': '40.9775',
                       'occupantNight': '', 'occupantDay': '10',
                       'deductible': '0.05'}
        second_asset = {'reco': '30000', 'area': '1000', 'taxonomy': 'RC_MR_LC',
                        'stco': '300000', 'lon': '28.6975', 'number': '100',
                        'coco': '2000', 'limit': '240000', 'lat': '40.9825',
                        'occupantNight': '', 'occupantDay': '15',
                        'deductible': '0.10'}

        expected_assets = [first_asset, second_asset]
        self.assertEqual(expected_assets, self.exp_reader.readassets())
Ejemplo n.º 4
0
class AnExposureTxtReaderShould(unittest.TestCase):
    def setUp(self):
        self.content = StringIO('expModId,assetCategory,description,stcoType,'
                                'stcoUnit,areaType,areaUnit,cocoType,'
                                'cocoUnit,recoType,recoUnit,taxonomySource\n'
                                'PAV01,buildings,Collection of existing '
                                'building in downtown Pavia,aggregated,USD,'
                                'per_asset,GBP,per_area,CHF,aggregated, '
                                'EUR,pavia taxonomy\n\n'
                                'lon,lat,taxonomy,stco,number,area,reco,coco,'
                                'occupantDay,occupantNight,deductible,limit\n'
                                '28.6925,40.9775,RC_MR_LC,40000,50,1500,4000,'
                                '1000,10,,0.05,32000\n'
                                '28.6975,40.9825,RC_MR_LC,300000,100,1000,'
                                '30000,2000,15,,0.10,240000')
        self.exp_reader = ExposureTxtReader(self.content)

    def test_read_meta_data(self):
        desc = 'Collection of existing building in downtown Pavia'
        expected_meta_data = dict(expModId='PAV01',
                                  assetCategory='buildings',
                                  description=desc,
                                  stcoType='aggregated',
                                  stcoUnit='USD',
                                  areaType='per_asset',
                                  areaUnit='GBP',
                                  cocoType='per_area',
                                  cocoUnit='CHF',
                                  recoType='aggregated',
                                  recoUnit='EUR',
                                  taxonomySource='pavia taxonomy')

        self.assertEqual(expected_meta_data, self.exp_reader.metadata)

    def test_read_assets(self):
        first_asset = {
            'reco': '4000',
            'area': '1500',
            'taxonomy': 'RC_MR_LC',
            'stco': '40000',
            'lon': '28.6925',
            'number': '50',
            'coco': '1000',
            'limit': '32000',
            'lat': '40.9775',
            'occupantNight': '',
            'occupantDay': '10',
            'deductible': '0.05'
        }
        second_asset = {
            'reco': '30000',
            'area': '1000',
            'taxonomy': 'RC_MR_LC',
            'stco': '300000',
            'lon': '28.6975',
            'number': '100',
            'coco': '2000',
            'limit': '240000',
            'lat': '40.9825',
            'occupantNight': '',
            'occupantDay': '15',
            'deductible': '0.10'
        }

        expected_assets = [first_asset, second_asset]
        self.assertEqual(expected_assets, self.exp_reader.readassets())