def test_get_exposure_layer_constraint(self):
     """Test for get_exposure_layer_constraint."""
     impact_function = FloodBuildingImpactFunction()
     expected_layer_constraint = [layer_vector_polygon, layer_vector_point]
     layer_constraints \
         = impact_function.Metadata.get_exposure_layer_constraint()
     message = 'Expected %s but got %s' % (expected_layer_constraint,
                                           layer_constraints)
     self.assertItemsEqual(expected_layer_constraint, layer_constraints,
                           message)
    def test_has_exposure(self):
        """Test for has_exposure API."""
        impact_function = EarthquakeBuildingImpactFunction()
        result = impact_function.Metadata.has_exposure(exposure_structure)
        expected_result = True
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertEqual(result, expected_result, message)

        impact_function = FloodBuildingImpactFunction()
        result = impact_function.Metadata.has_exposure(exposure_structure)
        expected_result = True
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertEqual(result, expected_result, message)
    def test_has_hazard(self):
        """Test for has_hazard API."""
        impact_function = EarthquakeBuildingImpactFunction()
        result = impact_function.Metadata.has_hazard(hazard_earthquake)
        expected_result = True
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertEqual(result, expected_result, message)

        impact_function = FloodBuildingImpactFunction()
        result = impact_function.Metadata.has_hazard(hazard_earthquake)
        expected_result = False
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertEqual(result, expected_result, message)
    def test_get_exposures(self):
        """Test for get_exposures API."""
        impact_function = EarthquakeBuildingImpactFunction()
        result = impact_function.Metadata.get_exposures()
        expected_result = [exposure_structure]
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertEqual(result, expected_result, message)

        impact_function = FloodBuildingImpactFunction()
        result = impact_function.Metadata.get_exposures()
        expected_result = []
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertNotEqual(result, expected_result, message)
    def test_get_hazards(self):
        """Test for get_hazards API."""
        impact_function = EarthquakeBuildingImpactFunction()
        result = impact_function.Metadata.get_hazards()
        expected_result = [hazard_earthquake]
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertEqual(result, expected_result, message)

        impact_function = FloodBuildingImpactFunction()
        result = impact_function.Metadata.get_hazards()
        expected_result = [hazard_flood, hazard_tsunami]
        message = ('I expect %s but I got %s.' % (expected_result, result))
        self.assertEqual(result, expected_result, message)