From 9a13cfd4e5e2be8946fd28ee1537448d526330f7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Sun, 7 Jan 2018 11:15:30 +1000 Subject: [PATCH] Remove composer tests relating to template substitution maps This API feature was not used anywhere in master, and is no longer available in the layouts engine. Better to use expression variables to meet the same use case. --- tests/src/python/test_qgscomposition.py | 57 ------------------------- 1 file changed, 57 deletions(-) diff --git a/tests/src/python/test_qgscomposition.py b/tests/src/python/test_qgscomposition.py index e40b4b4b33e..8733dad2614 100644 --- a/tests/src/python/test_qgscomposition.py +++ b/tests/src/python/test_qgscomposition.py @@ -45,47 +45,6 @@ class TestQgsComposition(unittest.TestCase): """Run after each test.""" pass - def testSubstitutionMap(self): - """Test that we can use degree symbols in substitutions. - """ - # Create a point and convert it to text containing a degree symbol. - myPoint = QgsPointXY(12.3, -33.33) - myCoordinates = QgsCoordinateFormatter.format(myPoint, QgsCoordinateFormatter.FormatDegreesMinutesSeconds, 2) - myTokens = myCoordinates.split(',') - myLongitude = myTokens[0] - myLatitude = myTokens[1] - myText = 'Latitude: %s, Longitude: %s' % (myLatitude, myLongitude) - - # Load the composition with the substitutions - myComposition = QgsComposition(QgsProject.instance()) - mySubstitutionMap = {'replace-me': myText} - myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt') - with open(myFile) as f: - myTemplateContent = f.read() - myDocument = QDomDocument() - myDocument.setContent(myTemplateContent) - myComposition.loadFromTemplate(myDocument, mySubstitutionMap) - - # We should be able to get map0 - myMap = myComposition.getComposerMapById(0) - myMessage = ('Map 0 could not be found in template %s', myFile) - assert myMap is not None, myMessage - - def testNoSubstitutionMap(self): - """Test that we can get a map if we use no text substitutions.""" - myComposition = QgsComposition(QgsProject.instance()) - myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt') - with open(myFile) as f: - myTemplateContent = f.read() - myDocument = QDomDocument() - myDocument.setContent(myTemplateContent) - myComposition.loadFromTemplate(myDocument) - - # We should be able to get map0 - myMap = myComposition.getComposerMapById(0) - myMessage = ('Map 0 could not be found in template %s', myFile) - assert myMap is not None, myMessage - def testPrintMapFromTemplate(self): """Test that we can get a map to render in the template.""" myPath = os.path.join(TEST_DATA_DIR, 'landsat.tif') @@ -135,22 +94,6 @@ class TestQgsComposition(unittest.TestCase): (myExpectedFileSize, myFileSize, myImagePath)) assert myFileSize > myExpectedFileSize, myMessage - def testSaveRestore(self): - # test that properties are restored correctly from XML - composition = QgsComposition(QgsProject.instance()) - composition.setName('test composition') - - doc = QDomDocument("testdoc") - elem = doc.createElement("qgis") - doc.appendChild(elem) - elem = doc.createElement("composer") - self.assertTrue(composition.writeXml(elem, doc)) - - composition2 = QgsComposition(QgsProject.instance()) - self.assertTrue(composition2.readXml(elem, doc)) - - self.assertEqual(composition.name(), 'test composition') - if __name__ == '__main__': unittest.main()