def setUp(self): """Fixture run before all tests""" self.maxDiff = None # show full diff for assert errors os.environ['LANG'] = 'en' DOCK.show_only_visible_layers_flag = True load_standard_layers(DOCK) DOCK.cboHazard.setCurrentIndex(0) DOCK.cboExposure.setCurrentIndex(0) DOCK.cboFunction.setCurrentIndex(0) DOCK.run_in_thread_flag = False DOCK.show_only_visible_layers_flag = False DOCK.set_layer_from_title_flag = False DOCK.zoom_to_impact_flag = False DOCK.hide_exposure_flag = False DOCK.show_intermediate_layers = False set_jakarta_extent() self._keywordIO = KeywordIO() self._defaults = get_defaults() # Set extent as Jakarta extent geo_crs = QgsCoordinateReferenceSystem() geo_crs.createFromSrid(4326) self.extent = extent_to_geo_array(CANVAS.extent(), geo_crs)
def test_check_aggregation_single_attribute(self): """Aggregation attribute is chosen correctly when there is only one attr available.""" file_list = ['kabupaten_jakarta_singlepart_1_good_attr.shp'] # add additional layers load_layers(file_list, clear_flag=False) attribute_key = get_defaults('AGGR_ATTR_KEY') # with 1 good aggregation attribute using # kabupaten_jakarta_singlepart_1_good_attr.shp result, message = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart 1 good attr') set_jakarta_extent(dock=DOCK) assert result, message # Press RUN # noinspection PyCallByClass,PyTypeChecker DOCK.accept() DOCK.runtime_keywords_dialog.accept() print attribute_key print DOCK.aggregator.attributes attribute = DOCK.aggregator.attributes[attribute_key] message = ( 'The aggregation should be KAB_NAME. Found: %s' % attribute) self.assertEqual(attribute, 'KAB_NAME', message)
def test_check_aggregation_single_attribute(self): """Aggregation attribute is chosen correctly when there is only one attr available.""" file_list = ['kabupaten_jakarta_singlepart_1_good_attr.shp'] # add additional layers load_layers(file_list, clear_flag=False) attribute_key = get_defaults('AGGR_ATTR_KEY') # with 1 good aggregation attribute using # kabupaten_jakarta_singlepart_1_good_attr.shp result, message = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart 1 good attr') set_jakarta_extent(dock=DOCK) assert result, message # Press RUN # noinspection PyCallByClass,PyTypeChecker DOCK.accept() DOCK.runtime_keywords_dialog.accept() print attribute_key print DOCK.aggregator.attributes attribute = DOCK.aggregator.attributes[attribute_key] message = ('The aggregation should be KAB_NAME. Found: %s' % attribute) self.assertEqual(attribute, 'KAB_NAME', message)
def test_aggregation_attribute_in_keywords(self): """Aggregation attribute is chosen correctly when present in keywords. """ attribute_key = get_defaults('AGGR_ATTR_KEY') # with KAB_NAME aggregation attribute defined in .keyword using # kabupaten_jakarta_singlepart.shp result, message = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart', aggregation_enabled_flag=True) set_jakarta_extent(dock=DOCK) assert result, message # Press RUN DOCK.accept() DOCK.runtime_keywords_dialog.accept() attribute = DOCK.aggregator.attributes[attribute_key] message = ('The aggregation should be KAB_NAME. Found: %s' % attribute) self.assertEqual(attribute, 'KAB_NAME', message)
def test_check_aggregation_none_in_keywords(self): """Aggregation attribute is chosen correctly when None in keywords.""" file_list = ['kabupaten_jakarta_singlepart_with_None_keyword.shp'] # add additional layers load_layers(file_list, clear_flag=False) attribute_key = get_defaults('AGGR_ATTR_KEY') # with None aggregation attribute defined in .keyword using # kabupaten_jakarta_singlepart_with_None_keyword.shp result, message = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart with None keyword') set_jakarta_extent(dock=DOCK) assert result, message # Press RUN DOCK.accept() DOCK.runtime_keywords_dialog.accept() attribute = DOCK.aggregator.attributes[attribute_key] message = ('The aggregation should be None. Found: %s' % attribute) assert attribute is None, message