コード例 #1
0
ファイル: test_map.py プロジェクト: roscoeKartoza/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_organisation_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
        self.assertTrue(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
            400563,  # Ubuntu 13.10_64
            450385,  # Ubuntu 14.04_64 AG
            413193,  # Ubuntu 14.04_64 TS pycharm
            416313,  # Ubuntu 14.04_64 TS make - TODO why is this?
            419483,  # Ubuntu 14.04_64 MB pycharm
            413193,  # Ubuntu 14.04_64 MB make - TODO why is this?
            418847,  # Ubuntu 14.04_64 IS pycharm
            412764,  # Ubuntu 14.04_64 IS make - TODO why is this?
            367934,  # Slackware64 14.0
            82263,  # Linux Mint 14_64
            85418,  # Windows 7 32bit
            88779,  # Windows 7 64bit
            436118,  # Jenkins ub 12.04
            433856,  # Travis
        ]
        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 プロジェクト: cccs-ip/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_organisation_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
        self.assertTrue(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
            400563,  # Ubuntu 13.10_64
            450385,  # Ubuntu 14.04_64 AG
            413193,  # Ubuntu 14.04_64 TS pycharm
            416313,  # Ubuntu 14.04_64 TS make - TODO why is this?
            419483,  # Ubuntu 14.04_64 MB pycharm
            413193,  # Ubuntu 14.04_64 MB make - TODO why is this?
            419036,  # Ubuntu 14.04_64 IS pycharm
            412764,  # Ubuntu 14.04_64 IS make - TODO why is this?
            367934,  # Slackware64 14.0
            82263,  # Linux Mint 14_64
            85418,  # Windows 7 32bit
            88779,  # Windows 7 64bit
            436118,   # Jenkins ub 12.04
            432703,  # Travis
        ]
        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)