Skip to content
Permalink
Browse files

Add test for writeEntry (not related to the bug)

... but since I wrote it ...
  • Loading branch information
elpaso committed Sep 18, 2018
1 parent a74b626 commit 9473d63cc45d00f650e872d03cfc301b0fbd7277
Showing with 17 additions and 1 deletion.
  1. +17 −1 tests/src/python/test_qgsproject.py
@@ -32,7 +32,7 @@
QgsMapCanvas)

from qgis.PyQt.QtTest import QSignalSpy
from qgis.PyQt.QtCore import QT_VERSION_STR, QTemporaryFile, QTemporaryDir
from qgis.PyQt.QtCore import QT_VERSION_STR, QTemporaryDir
import sip

from qgis.testing import start_app, unittest
@@ -1105,6 +1105,22 @@ def testProjectTitleWithPeriod(self):
self.assertEqual(p0.baseName(), '2.18.21')
self.assertEqual(p1.baseName(), 'qgis-3.2.0')

def testWriteEntry(self):

tmpDir = QTemporaryDir()
tmpFile = "{}/project.qgs".format(tmpDir.path())

# zip with existing file
project = QgsProject()
query = 'select * from "sample DH" where "sample DH"."Elev" > 130 and "sample DH"."Elev" < 140'
self.assertTrue(project.writeEntry('myscope', 'myentry', query))
self.assertTrue(project.write(tmpFile))

self.assertTrue(project.read(tmpFile))
q, ok = project.readEntry('myscope', 'myentry')
self.assertTrue(ok)
self.assertEqual(q, query)


if __name__ == '__main__':
unittest.main()

0 comments on commit 9473d63

Please sign in to comment.
You can’t perform that action at this time.