Esempio n. 1
0
    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='Need evacuation',
            function_id='Flood Evacuation Function')
        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(DOCK)
        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)
Esempio n. 2
0
    def test_issue306(self):
        """Issue306: CANVAS doesnt add generated layers in tests.

        See https://github.com/AIFDR/inasafe/issues/306"""

        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction')
        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(self.dock)
        before_count = len(CANVAS.layers())
        # print 'Before count %s' % before_count

        # Press RUN
        self.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)
Esempio n. 3
0
    def test_issue306(self):
        """Issue306: CANVAS doesnt add generated layers in tests.

        See https://github.com/AIFDR/inasafe/issues/306
        """

        settings = QtCore.QSettings()
        settings.setValue('inasafe/analysis_extents_mode', 'HazardExposure')

        result, message = setup_scenario(
            self.dock,
            hazard='Continuous Flood',
            exposure='Population',
            function='Need evacuation',
            function_id='FloodEvacuationRasterHazardFunction')
        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(self.dock)
        before_count = len(CANVAS.layers())

        # Press RUN
        self.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.assertEqual(before_count, after_count - 1, message)
Esempio n. 4
0
 def test_new_layers_show_in_canvas(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().addMapLayers([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())
Esempio n. 5
0
 def test_new_layers_show_in_canvas(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().addMapLayers([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_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='Continuous Flood',
            exposure='Population',
            function_id='FloodEvacuationRasterHazardFunction',
            aggregation_layer=u"Dístríct's of Jakarta")
        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
Esempio n. 7
0
    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