def test_addClassToLegend(self): """Test we can add a class to the map legend.""" myLayer, myType = loadLayer('test_shakeimpact.shp') del myType myMap = ISMap(IFACE) myMap.setImpactLayer(myLayer) myMap.legend = None myColour = QtGui.QColor(12, 34, 126) myMap.addClassToLegend(myColour, theMin=None, theMax=None, theCategory=None, theLabel='bar') myMap.addClassToLegend(myColour, theMin=None, theMax=None, theCategory=None, theLabel='foo') myPath = os.path.join(getTempDir(), 'addClassToLegend.png') myMap.legend.save(myPath, 'PNG') # As we have discovered, different versions of Qt and # OS platforms cause different output, so hashes are a list # of 'known good' renders. myExpectedHashes = ['', # win '67c0f45792318298664dd02cc0ac94c3', # ub12.04xiner 'ea0702782c2ed5d950c427fbe1743858', # ub11.10-64 '53e0ba1144e071ad41756595d29bf444', # ub12.04 '0681c3587305074bc9272f456fb4dd09', # ub12.04 xvfb # ub11.04-64 laptop '', ] assertHashesForFile(myExpectedHashes, myPath)
def test_addClassToLegend(self): """Test we can add a class to the map legend.""" myLayer, myType = loadLayer('test_shakeimpact.shp') del myType myMap = ISMap(IFACE) myMap.setImpactLayer(myLayer) myMap.legend = None myColour = QtGui.QColor(12, 34, 126) myMap.addClassToLegend(myColour, theMin=None, theMax=None, theCategory='foo', theLabel='bar') myMap.addClassToLegend(myColour, theMin=None, theMax=None, theCategory='foo', theLabel='foo') myPath = os.path.join(getTempDir(), 'addClassToLegend.png') myMap.legend.save(myPath, 'PNG') myExpectedHash = None if os.name is'nt': # windows renders fonts slightly differently myExpectedHash = '658e8dc0bf8b9a09b36994abf9242099' else: myExpectedHash = 'ea0702782c2ed5d950c427fbe1743858' assertHashForFile(myExpectedHash, myPath)
def test_addClassToLegend(self): """Test we can add a class to the map legend.""" myLayer, myType = loadLayer('test_shakeimpact.shp') del myType myMap = ISMap(IFACE) myMap.setImpactLayer(myLayer) myMap.legend = None myColour = QtGui.QColor(12, 34, 126) myMap.addClassToLegend(myColour, theMin=None, theMax=None, theCategory='foo', theLabel='bar') myMap.addClassToLegend(myColour, theMin=None, theMax=None, theCategory='foo', theLabel='foo') myPath = os.path.join(getTempDir(), 'addClassToLegend.png') myMap.legend.save(myPath, 'PNG') # As we have discovered, different versions of Qt and # OS platforms cause different output, so hashes are a list # of 'known good' renders. myExpectedHashes = ['658e8dc0bf8b9a09b36994abf9242099', # win 'ea0702782c2ed5d950c427fbe1743858', # ub11.10 '944cee3eb9d916816b60ef41e8069683', # ub12.04 # ub11.04-64 laptop '4f98b1ddef2d72bd38b2f220ec7e01cc', ] assertHashesForFile(myExpectedHashes, myPath)
def addSymbolToLegend(self): """Test we can add a symbol to the legend.""" myLayer, myType = loadLayer('test_floodimpact.tif') del myType myMap = ISMap(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(getTempDir(), 'addSymbolToLegend.png') myMap.legend.save(myPath, 'PNG') myExpectedHash = '1234' assertHashForFile(myExpectedHash, myPath)