Example #1
0
    def testRemoteSvgBadMime(self):
        """Test fetching remote svg with bad mime type"""
        url = 'http://localhost:{}/qgis_local_server/logo.png'.format(str(TestQgsSvgCache.port))
        image, in_cache = QgsApplication.svgCache().svgAsImage(url, 100, fill=QColor(0, 0, 0), stroke=QColor(0, 0, 0),
                                                               strokeWidth=0.1, widthScaleFactor=1)
        # first should be waiting image
        self.assertTrue(self.imageCheck('Remote SVG bad MIME type', 'waiting_svg', image))

        # second should be correct image
        self.waitForFetch()
        image, in_cache = QgsApplication.svgCache().svgAsImage(url, 100, fill=QColor(0, 0, 0), stroke=QColor(0, 0, 0),
                                                               strokeWidth=0.1, widthScaleFactor=1)
        self.assertTrue(self.imageCheck('Remote SVG bad MIME type', 'bad_svg', image))
Example #2
0
    def testRemoteSvgAsText(self):
        """Test fetching remote svg with text mime format - e.g. github raw svgs"""
        url = 'http://localhost:{}/qgis_local_server/svg_as_text.txt'.format(str(TestQgsSvgCache.port))
        image, in_cache = QgsApplication.svgCache().svgAsImage(url, 100, fill=QColor(0, 0, 0), stroke=QColor(0, 0, 0),
                                                               strokeWidth=0.1, widthScaleFactor=1)
        # first should be waiting image
        self.assertTrue(self.imageCheck('Remote SVG as Text', 'waiting_svg', image))

        self.waitForFetch()
        # second should be correct image
        image, in_cache = QgsApplication.svgCache().svgAsImage(url, 100, fill=QColor(0, 0, 0), stroke=QColor(0, 0, 0),
                                                               strokeWidth=0.1, widthScaleFactor=1)
        # first should be waiting image
        self.assertTrue(self.imageCheck('Remote SVG as Text', 'remote_svg', image))
Example #3
0
    def testRemoteSvgMissing(self):
        """Test fetching remote svg with bad url"""
        url = 'http://localhost:{}/qgis_local_server/xxx.svg'.format(str(TestQgsSvgCache.port))  # oooo naughty
        image, in_cache = QgsApplication.svgCache().svgAsImage(url, 100, fill=QColor(0, 0, 0), stroke=QColor(0, 0, 0),
                                                               strokeWidth=0.1, widthScaleFactor=1)

        self.assertTrue(self.imageCheck('Remote SVG missing', 'waiting_svg', image))
Example #4
0
    def testRemoteSvgMissing(self):
        """Test fetching remote svg with bad url"""
        url = 'http://localhost:{}/qgis_local_server/xxx.svg'.format(
            str(TestQgsSvgCache.port))  # oooo naughty
        image, in_cache = QgsApplication.svgCache().svgAsImage(
            url,
            100,
            fill=QColor(0, 0, 0),
            stroke=QColor(0, 0, 0),
            strokeWidth=0.1,
            widthScaleFactor=1)

        self.assertTrue(
            self.imageCheck('Remote SVG missing', 'waiting_svg', image))
Example #5
0
    def testRemoteSVG(self):
        """Test fetching remote svg."""
        url = 'http://localhost:{}/qgis_local_server/sample_svg.svg'.format(
            str(TestQgsSvgCache.port))
        image, in_cache = QgsApplication.svgCache().svgAsImage(
            url,
            100,
            fill=QColor(0, 0, 0),
            stroke=QColor(0, 0, 0),
            strokeWidth=0.1,
            widthScaleFactor=1)
        # first should be waiting image
        self.assertTrue(self.imageCheck('Remote SVG', 'waiting_svg', image))
        self.waitForFetch()

        # second should be correct image
        image, in_cache = QgsApplication.svgCache().svgAsImage(
            url,
            100,
            fill=QColor(0, 0, 0),
            stroke=QColor(0, 0, 0),
            strokeWidth=0.1,
            widthScaleFactor=1)
        self.assertTrue(self.imageCheck('Remote SVG', 'remote_svg', image))
Example #6
0
 def testMembers(self):
     self.assertTrue(QgsApplication.actionScopeRegistry())
     # self.assertTrue(QgsApplication.annotationRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.colorSchemeRegistry())
     self.assertTrue(QgsApplication.fieldFormatterRegistry())
     self.assertTrue(QgsApplication.gpsConnectionRegistry())
     self.assertTrue(QgsApplication.messageLog())
     self.assertTrue(QgsApplication.paintEffectRegistry())
     self.assertTrue(QgsApplication.pluginLayerRegistry())
     self.assertTrue(QgsApplication.processingRegistry())
     self.assertTrue(QgsApplication.profiler())
     # self.assertTrue(QgsApplication.rasterRendererRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.rendererRegistry())
     self.assertTrue(QgsApplication.svgCache())
     self.assertTrue(QgsApplication.symbolLayerRegistry())
     self.assertTrue(QgsApplication.taskManager())
 def testMembers(self):
     self.assertTrue(QgsApplication.actionScopeRegistry())
     # self.assertTrue(QgsApplication.annotationRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.colorSchemeRegistry())
     self.assertTrue(QgsApplication.fieldFormatterRegistry())
     self.assertTrue(QgsApplication.gpsConnectionRegistry())
     self.assertTrue(QgsApplication.messageLog())
     self.assertTrue(QgsApplication.paintEffectRegistry())
     self.assertTrue(QgsApplication.pluginLayerRegistry())
     self.assertTrue(QgsApplication.processingRegistry())
     self.assertTrue(QgsApplication.profiler())
     # self.assertTrue(QgsApplication.rasterRendererRegistry()) NOT AVAILABLE IN BINDINGS
     self.assertTrue(QgsApplication.rendererRegistry())
     self.assertTrue(QgsApplication.svgCache())
     self.assertTrue(QgsApplication.symbolLayerRegistry())
     self.assertTrue(QgsApplication.taskManager())
Example #8
0
    def setUp(self):
        self.report = "<h1>Python QgsSvgCache Tests</h1>\n"

        self.fetched = True
        QgsApplication.svgCache().remoteSvgFetched.connect(self.svgFetched)
Example #9
0
    def setUp(self):
        self.report = "<h1>Python QgsSvgCache Tests</h1>\n"

        self.fetched = True
        QgsApplication.svgCache().remoteSvgFetched.connect(self.svgFetched)
Example #10
0
 def testRemoteSVG(self):
     """Test fetching remote svg."""
     url = 'http://localhost:{}/qgis_local_server/sample_svg.svg'.format(str(TestQgsSvgCache.port))
     image, in_cache = QgsApplication.svgCache().svgAsImage(url, 100, fill=QColor(0, 0, 0), stroke=QColor(0, 0, 0),
                                                            strokeWidth=0.1, widthScaleFactor=1)
     self.assertTrue(self.imageCheck('Remote SVG', 'remote_svg', image))