Skip to content

Commit

Permalink
Add test for writeEntry (not related to the bug)
Browse files Browse the repository at this point in the history
... but since I wrote it ...
  • Loading branch information
elpaso committed Sep 18, 2018
1 parent a74b626 commit 9473d63
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/src/python/test_qgsproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.