def test_aggregation_summary(self): """Test we can aggregate the aggregate hazard to the aggregation.""" aggregate_hazard = load_test_vector_layer( 'gisv4', 'intermediate', 'aggregate_classified_hazard_summary.geojson') aggregation = load_test_vector_layer( 'gisv4', 'aggregation', 'aggregation_cleaned.geojson', clone=True) number_of_fields = aggregation.fields().count() layer = aggregation_summary(aggregate_hazard, aggregation) check_inasafe_fields(layer) # I need the number of unique exposure pattern = exposure_count_field['key'] pattern = pattern.replace('%s', '') unique_exposure = [] inasafe_fields = aggregate_hazard.keywords['inasafe_fields'] for key, name_field in inasafe_fields.iteritems(): if key.endswith(pattern): unique_exposure.append(key.replace(pattern, '')) self.assertEqual( layer.fields().count(), len(unique_exposure) + number_of_fields + 1 )
def test_aggregation_summary(self): """Test we can aggregate the aggregate hazard to the aggregation.""" aggregate_hazard = load_test_vector_layer( 'gisv4', 'intermediate', 'aggregate_classified_hazard_summary.geojson') aggregation = load_test_vector_layer( 'gisv4', 'aggregation', 'aggregation_cleaned.geojson', clone=True) number_of_fields = aggregation.fields().count() layer = aggregation_summary(aggregate_hazard, aggregation) check_inasafe_fields(layer) # I need the number of unique exposure pattern = exposure_count_field['key'] pattern = pattern.replace('%s', '') unique_exposure = [] inasafe_fields = aggregate_hazard.keywords['inasafe_fields'] for key, name_field in inasafe_fields.iteritems(): if key.endswith(pattern): unique_exposure.append(key.replace(pattern, '')) self.assertEqual( layer.fields().count(), len(unique_exposure) + number_of_fields + 1 )