def test_hazards_for_layer(self): """Test for hazards_for_layer""" self.maxDiff = None hazards = hazards_for_layer('polygon', 'single_event') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'] ] self.assertItemsEqual(hazards, expected) hazards = hazards_for_layer('polygon') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'] ] self.assertItemsEqual(hazards, expected) hazards = hazards_for_layer('raster', 'single_event') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'] ] self.assertItemsEqual(hazards, expected)
def test_hazards_for_layer(self): """Test for hazards_for_layer""" self.maxDiff = None hazards = hazards_for_layer('polygon') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'], hazard_dam_break['key'] ] self.assertEqual(sorted(hazards), sorted(expected)) hazards = hazards_for_layer('polygon') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'], hazard_dam_break['key'] ] self.assertEqual(sorted(hazards), sorted(expected)) hazards = hazards_for_layer('raster') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'], hazard_dam_break['key'] ] self.assertEqual(sorted(hazards), sorted(expected))
def test_hazards_for_layer(self): """Test for hazards_for_layer""" self.maxDiff = None hazards = hazards_for_layer('polygon') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'], hazard_dam_break['key'] ] self.assertEqual(sorted(hazards), sorted(expected)) hazards = hazards_for_layer('polygon') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'], hazard_dam_break['key'] ] self.assertEqual(sorted(hazards), sorted(expected)) hazards = hazards_for_layer('raster') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'], hazard_dam_break['key'] ] self.assertEqual(sorted(hazards), sorted(expected))
def test_hazards_for_layer(self): """Test for hazards_for_layer""" self.maxDiff = None hazards = hazards_for_layer( 'polygon', 'single_event') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'] ] self.assertItemsEqual(hazards, expected) hazards = hazards_for_layer('polygon') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcano['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'] ] self.assertItemsEqual(hazards, expected) hazards = hazards_for_layer( 'raster', 'single_event') hazards = [hazard['key'] for hazard in hazards] expected = [ hazard_flood['key'], hazard_tsunami['key'], hazard_earthquake['key'], hazard_volcanic_ash['key'], hazard_cyclone['key'], hazard_generic['key'] ] self.assertItemsEqual(hazards, expected)
def subcategories_for_layer(self): """Return a list of valid subcategories for a layer. Subcategory is hazard type or exposure type. :returns: A list where each value represents a valid subcategory. :rtype: list """ purpose = self.parent.step_kw_purpose.selected_purpose() layer_geometry_key = self.parent.get_layer_geometry_key() if purpose == layer_purpose_hazard: return hazards_for_layer(layer_geometry_key) elif purpose == layer_purpose_exposure: return exposures_for_layer(layer_geometry_key)
def subcategories_for_layer(self): """Return a list of valid subcategories for a layer. Subcategory is hazard type or exposure type. :returns: A list where each value represents a valid subcategory. :rtype: list """ purpose = self.parent.step_kw_purpose.selected_purpose() layer_geometry_key = self.parent.get_layer_geometry_key() if purpose == layer_purpose_hazard: return hazards_for_layer(layer_geometry_key) elif purpose == layer_purpose_exposure: return exposures_for_layer(layer_geometry_key)