def test_issue306(self): """Issue306: CANVAS doesnt add generated layers in tests See https://github.com/AIFDR/inasafe/issues/306""" result, message = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='Penduduk Jakarta', function='HKVtest', function_id='HKVtest') self.assertTrue(result, message) LOGGER.info("Canvas list before:\n%s" % canvas_list()) # Enable on-the-fly reprojection set_canvas_crs(GOOGLECRS, True) set_jakarta_google_extent() before_count = len(CANVAS.layers()) #print 'Before count %s' % before_count # Press RUN DOCK.accept() # test issue #306 after_count = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n%s" % canvas_list()) message = ('Layer was not added to canvas (%s before, %s after)' % ( before_count, after_count)) #print 'After count %s' % after_count self.assertTrue(before_count == after_count - 1, message)
def test_newLayersShowInCanvas(self): """Check that when we add a layer we can see it in the canvas list.""" LOGGER.info("Canvas list before:\n%s" % canvas_list()) myBeforeCount = len(CANVAS.layers()) myPath = join(TESTDATA, 'polygon_0.shp') myLayer = QgsVectorLayer(myPath, 'foo', 'ogr') QgsMapLayerRegistry.instance().addMapLayer(myLayer) myAfterCount = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n%s" % canvas_list()) myMessage = ('Layer was not added to canvas (%s before, %s after)' % (myBeforeCount, myAfterCount)) assert myBeforeCount == myAfterCount - 1, myMessage QgsMapLayerRegistry.instance().removeMapLayer(myLayer.id())
def test_newLayersShowInCanvas(self): """Check that when we add a layer we can see it in the canvas list.""" LOGGER.info("Canvas list before:\n%s" % canvas_list()) myBeforeCount = len(CANVAS.layers()) myPath = join(TESTDATA, 'polygon_0.shp') myLayer = QgsVectorLayer(myPath, 'foo', 'ogr') QgsMapLayerRegistry.instance().addMapLayer(myLayer) myAfterCount = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n%s" % canvas_list()) myMessage = ('Layer was not added to canvas (%s before, %s after)' % (myBeforeCount, myAfterCount)) assert myBeforeCount == myAfterCount - 1, myMessage QgsMapLayerRegistry.instance().removeMapLayer(myLayer.id())
def test_newLayersShowInCanvas(self): """Check that when we add a layer we can see it in the canvas list.""" LOGGER.info("Canvas list before:\n%s" % canvas_list()) before_count = len(CANVAS.layers()) layer_path = join(TESTDATA, 'polygon_0.shp') layer = QgsVectorLayer(layer_path, 'foo', 'ogr') QgsMapLayerRegistry.instance().addMapLayer(layer) after_count = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n%s" % canvas_list()) message = ( 'Layer was not added to canvas (%s before, %s after)' % (before_count, after_count)) self.assertTrue(before_count == after_count - 1, message) QgsMapLayerRegistry.instance().removeMapLayer(layer.id())
def test_checkPostProcessingLayersVisibility(self): """Generated layers are not added to the map registry.""" myRunButton = DOCK.pbnRunStop # with KAB_NAME aggregation attribute defined in .keyword using # kabupaten_jakarta_singlepart.shp myResult, myMessage = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function='Need evacuation', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart') assert myResult, myMessage LOGGER.info("Registry list before:\n%s" % QgsMapLayerRegistry.instance().mapLayers()) #one layer (the impact) should have been added myExpectedCount = len(CANVAS.layers()) + 1 # Press RUN # noinspection PyCallByClass,PyTypeChecker QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton) DOCK.runtimeKeywordsDialog.accept() myAfterCount = len(CANVAS.layers()) LOGGER.info("Registry list after:\n%s" % QgsMapLayerRegistry.instance().mapLayers()) myMessage = ('Expected %s items in canvas, got %s' % (myExpectedCount, myAfterCount)) assert myExpectedCount == myAfterCount, myMessage # Now run again showing intermediate layers DOCK.showIntermediateLayers = True # Press RUN # noinspection PyCallByClass,PyTypeChecker QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton) DOCK.runtimeKeywordsDialog.accept() #one layer (the impact) should have been added myExpectedCount += 2 myAfterCount = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n %s" % canvas_list()) myMessage = ('Expected %s items in canvas, got %s' % (myExpectedCount, myAfterCount)) # We expect two more since we enabled showing intermedate layers assert myExpectedCount == myAfterCount, myMessage
def test_checkPostProcessingLayersVisibility(self): """Generated layers are not added to the map registry.""" myRunButton = DOCK.pbnRunStop # with KAB_NAME aggregation attribute defined in .keyword using # kabupaten_jakarta_singlepart.shp myResult, myMessage = setup_scenario( DOCK, hazard='A flood in Jakarta like in 2007', exposure='People', function='Need evacuation', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart') assert myResult, myMessage LOGGER.info("Registry list before:\n%s" % QgsMapLayerRegistry.instance().mapLayers()) #one layer (the impact) should have been added myExpectedCount = len(CANVAS.layers()) + 1 # Press RUN # noinspection PyCallByClass,PyTypeChecker QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton) DOCK.runtimeKeywordsDialog.accept() myAfterCount = len(CANVAS.layers()) LOGGER.info("Registry list after:\n%s" % QgsMapLayerRegistry.instance().mapLayers()) myMessage = ('Expected %s items in canvas, got %s' % (myExpectedCount, myAfterCount)) assert myExpectedCount == myAfterCount, myMessage # Now run again showing intermediate layers DOCK.showIntermediateLayers = True # Press RUN # noinspection PyCallByClass,PyTypeChecker QTest.mouseClick(myRunButton, QtCore.Qt.LeftButton) DOCK.runtimeKeywordsDialog.accept() #one layer (the impact) should have been added myExpectedCount += 2 myAfterCount = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n %s" % canvas_list()) myMessage = ('Expected %s items in canvas, got %s' % (myExpectedCount, myAfterCount)) # We expect two more since we enabled showing intermedate layers assert myExpectedCount == myAfterCount, myMessage
def test_check_postprocessing_layers_visibility(self): """Generated layers are not added to the map registry.""" # Explicitly disable showing intermediate layers DOCK.show_intermediate_layers = False # 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='Need evacuation', function_id='Flood Evacuation Function', aggregation_layer='kabupaten jakarta singlepart') assert result, message #LOGGER.info("Registry list before:\n%s" % # QgsMapLayerRegistry.instance().mapLayers()) #one layer (the impact) should have been added expected_count = len(CANVAS.layers()) + 1 # # # Press RUN DOCK.accept() # no KW dialog will popuo due to complete keywords after_count = len(CANVAS.layers()) #LOGGER.info("Registry list after:\n%s" % # QgsMapLayerRegistry.instance().mapLayers()) message = ( 'Expected %s items in canvas, got %s' % (expected_count, after_count)) assert expected_count == after_count, message # Now run again showing intermediate layers DOCK.show_intermediate_layers = True # Press RUN DOCK.accept() # no KW dialog will popup due to complete keywords #one layer (the impact) should have been added expected_count += 2 after_count = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n %s" % canvas_list()) message = ( 'Expected %s items in canvas, got %s' % (expected_count, after_count)) # We expect two more since we enabled showing intermediate layers assert expected_count == after_count, message
def test_check_postprocessing_layers_visibility(self): """Generated layers are not added to the map registry.""" # Explicitly disable showing intermediate layers DOCK.show_intermediate_layers = False # 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') set_jakarta_extent(dock=DOCK) assert result, message # LOGGER.info("Registry list before:\n%s" % # QgsMapLayerRegistry.instance().mapLayers()) # one layer (the impact) should have been added expected_count = len(CANVAS.layers()) + 1 # # Press RUN DOCK.accept() # no KW dialog will popuo due to complete keywords after_count = len(CANVAS.layers()) # LOGGER.info("Registry list after:\n%s" % # QgsMapLayerRegistry.instance().mapLayers()) message = ('Expected %s items in canvas, got %s' % (expected_count, after_count)) assert expected_count == after_count, message # Now run again showing intermediate layers DOCK.show_intermediate_layers = True # Press RUN DOCK.accept() # no KW dialog will popup due to complete keywords # one layer (the impact) should have been added expected_count += 2 after_count = len(CANVAS.layers()) LOGGER.info("Canvas list after:\n %s" % canvas_list()) message = ('Expected %s items in canvas, got %s' % (expected_count, after_count)) # We expect two more since we enabled showing intermediate layers assert expected_count == after_count, message