コード例 #1
0
ファイル: test_map.py プロジェクト: opengeogroep/inasafe
    def test_custom_logo(self):
        """Test that setting user-defined logo works"""
        LOGGER.info('Testing custom_logo')
        layer, _ = load_layer('test_shakeimpact.shp')
        canvas_layer = QgsMapCanvasLayer(layer)
        CANVAS.setLayerSet([canvas_layer])
        rect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
        CANVAS.setExtent(rect)
        CANVAS.refresh()
        report = Map(IFACE)
        report.set_impact_layer(layer)
        report.set_logo(":/plugins/inasafe/logo-flower.png")
        out_path = unique_filename(prefix='mapCustomLogoTest',
                                   suffix='.pdf',
                                   dir=temp_dir('test'))
        report.make_pdf(out_path)
        LOGGER.debug(out_path)
        message = 'Rendered output does not exist: %s' % out_path
        assert os.path.exists(out_path), message
        # pdf rendering is non deterministic so we can't do a hash check
        # test_renderComposition renders just the image instead of pdf
        # so we hash check there and here we just do a basic minimum file
        # size check.
        out_size = os.stat(out_path).st_size

        # Note: You should replace, not append the numbers for a given
        # platform. Also note that this test will break every time the
        # version number of InaSAFE changes so we should ultimately come up
        # with a lower maintenance test strategy.

        expected_sizes = [
            402083,  # Ubuntu 13.04_64
            388095,  # Slackware64 14.0
        ]
        message = '%s\nExpected rendered map pdf to be in %s, got %s' % (
            out_path, expected_sizes, out_size)
        self.assertIn(out_size, expected_sizes, message)
コード例 #2
0
ファイル: test_map.py プロジェクト: vdeparday/inasafe
    def test_customLogo(self):
        """Test that setting user-defined logo works"""
        LOGGER.info('Testing defaultTemplate')
        myLayer, _ = load_layer('test_shakeimpact.shp')
        myCanvasLayer = QgsMapCanvasLayer(myLayer)
        CANVAS.setLayerSet([myCanvasLayer])
        myRect = QgsRectangle(106.7894, -6.2308, 106.8004, -6.2264)
        CANVAS.setExtent(myRect)
        CANVAS.refresh()
        myMap = Map(IFACE)
        myMap.set_impact_layer(myLayer)
        myMap.set_logo(":/plugins/inasafe/logo-flower.png")
        myPath = unique_filename(prefix='mapCustomLogoTest',
                                 suffix='.pdf',
                                 dir=temp_dir('test'))
        myMap.make_pdf(myPath)
        LOGGER.debug(myPath)
        myMessage = 'Rendered output does not exist: %s' % myPath
        assert os.path.exists(myPath), myMessage
        # pdf rendering is non deterministic so we can't do a hash check
        # test_renderComposition renders just the image instead of pdf
        # so we hash check there and here we just do a basic minimum file
        # size check.
        mySize = os.stat(myPath).st_size

        # Note: You should replace, not append the numbers for a given
        # platform. Also note that this test will break every time the
        # version number of InaSAFE changes so we should ultimately come up
        # with a lower maintenance test strategy.

        myExpectedSizes = [
            397575,  # Slackware64 14.0
        ]
        myMessage = '%s\nExpected rendered map pdf to be in %s, got %s' % (
            myPath, myExpectedSizes, mySize)
        self.assertIn(mySize, myExpectedSizes, myMessage)