Esempio n. 1
0
    def test_get_exposures_fails(self):
        client = Client()
        with self.assertRaises(ValueError) as cm:
            client.get_exposures(exposures_type='river_flood',
                                 properties={
                                     'country_iso3alpha': 'AUT',
                                     'fin_mode': 'pop',
                                     'exponents': '(0,1)'
                                 },
                                 dump_dir=DATA_DIR)
        self.assertIn(
            'Valid exposures types are a subset of CLIMADA exposures types. Currently',
            str(cm.exception))

        with self.assertRaises(Client.AmbiguousResult) as cm:
            client.get_exposures(exposures_type='litpop',
                                 properties={'country_iso3alpha': 'AUT'},
                                 dump_dir=DATA_DIR)
        self.assertIn('there are several datasets meeting the requirements',
                      str(cm.exception))
Esempio n. 2
0
 def test_get_exposures(self):
     client = Client()
     exposures = client.get_exposures(exposures_type='litpop',
                                      properties={
                                          'country_iso3alpha': 'AUT',
                                          'fin_mode': 'pop',
                                          'exponents': '(0,1)'
                                      },
                                      dump_dir=DATA_DIR)
     self.assertEqual(len(exposures.gdf), 5782)
     self.assertEqual(np.unique(exposures.gdf.region_id), 40)
     self.assertTrue('[0, 1]' in exposures.tag.description)
     self.assertTrue('pop' in exposures.tag.description)
     exposures