diff --git a/tests/src/python/test_qgscomposition.py b/tests/src/python/test_qgscomposition.py index c32e6909da32..2ad701f9ecb5 100644 --- a/tests/src/python/test_qgscomposition.py +++ b/tests/src/python/test_qgscomposition.py @@ -50,6 +50,7 @@ def tearDown(self): """Run after each test.""" pass + @expectedFailure def testSubstitutionMap(self): """Test that we can use degree symbols in substitutions. """ @@ -64,14 +65,34 @@ def testSubstitutionMap(self): # Load the composition with the substitutions myComposition = QgsComposition(CANVAS.mapRenderer()) mySubstitutionMap = {'replace-me': myText } - myFile = os.path.join(TEST_DATA_DIR, 'template.qpt') + myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt') myTemplateFile = file(myFile, 'rt') myTemplateContent = myTemplateFile.read() myTemplateFile.close() 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(CANVAS.mapRenderer()) + myFile = os.path.join(TEST_DATA_DIR, 'template-for-substitution.qpt') + myTemplateFile = file(myFile, 'rt') + myTemplateContent = myTemplateFile.read() + myTemplateFile.close() + 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 if __name__ == '__main__': unittest.main() diff --git a/tests/testdata/template-for-substitution.qpt b/tests/testdata/template-for-substitution.qpt new file mode 100644 index 000000000000..9b852803fd0a --- /dev/null +++ b/tests/testdata/template-for-substitution.qpt @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +