def Xtest_renderTable(self): """Test that html renders nicely. Commented out for now until we work out how to get webkit to do offscreen rendering nicely.""" myFilename = 'test_floodimpact.tif' myLayer, myType = loadLayer(myFilename) CANVAS.refresh() del myType myMessage = 'Layer is not valid: %s' % myFilename assert myLayer.isValid(), myMessage myMap = Map(IFACE) myMap.setImpactLayer(myLayer) myPixmap = myMap.renderImpactTable() assert myPixmap is not None myExpectedWidth = 500 myExpectedHeight = 300 myMessage = 'Invalid width - got %s expected %s' % ( myPixmap.width(), myExpectedWidth) assert myPixmap.width() == myExpectedWidth, myMessage myMessage = 'Invalid height - got %s expected %s' % ( myPixmap.height(), myExpectedHeight) assert myPixmap.height() == myExpectedHeight myPath = os.path.join(temp_dir(), 'renderImpactTable.png') myPixmap.save(myPath, 'PNG') myExpectedHash = 'c9164d5c2bb85c6081905456ab827f3e' assertHashForFile(myExpectedHash, myPath)
def test_httpDownload(self): myManager = QNetworkAccessManager(PARENT) # NOTE(gigih): # this is the hash of google front page. # I think we can safely assume that the content # of google.com never changes (probably). # myHash = 'd4b691cd9d99117b2ea34586d3e7eeb8' myUrl = 'http://google.com' myTempFilePath = tempfile.mktemp() httpDownload(myManager, myUrl, myTempFilePath) assertHashForFile(myHash, myTempFilePath)
def test_httpDownload(self): myManager = QNetworkAccessManager(PARENT) # NOTE(gigih): # this is the hash of google front page. # I think we can safely assume that the content # of google.com never changes (probably). # myHash = "d4b691cd9d99117b2ea34586d3e7eeb8" myUrl = "http://google.com" myTempFilePath = tempfile.mktemp() httpDownload(myManager, myUrl, myTempFilePath) assertHashForFile(myHash, myTempFilePath)
def addSymbolToLegend(self): """Test we can add a symbol to the legend.""" myLayer, myType = loadLayer('test_floodimpact.tif') del myType myMap = Map(IFACE) myMap.setImpactLayer(myLayer) myMap.legend = None mySymbol = QgsSymbol() mySymbol.setColor(QtGui.QColor(12, 34, 56)) myMap.addSymbolToLegend(mySymbol, theMin=0, theMax=2, theCategory=None, theLabel='Foo') myPath = os.path.join(temp_dir(), 'addSymbolToLegend.png') myMap.legend.save(myPath, 'PNG') myExpectedHash = '1234' assertHashForFile(myExpectedHash, myPath)