Skip to content
Permalink
Browse files

switch tests to pyqt wrappers

  • Loading branch information
jef-n committed Mar 21, 2016
1 parent 719182f commit f41304637cff7dfb56d34fa3df8b75d1b3810a5b
Showing with 236 additions and 384 deletions.
  1. +1 −1 python/plugins/processing/tests/GdalAlgorithmsTest.py
  2. +1 −1 python/plugins/processing/tests/QgisAlgorithmsTest.py
  3. +1 −1 python/testing/__init__.py
  4. +2 −2 python/testing/mocked.py
  5. +1 −1 tests/src/python/qgis_interface.py
  6. +3 −3 tests/src/python/qgscompositionchecker.py
  7. +1 −1 tests/src/python/test_provider_memory.py
  8. +4 −16 tests/src/python/test_provider_mssql.py
  9. +3 −5 tests/src/python/test_provider_postgres.py
  10. +3 −5 tests/src/python/test_provider_shapefile.py
  11. +5 −7 tests/src/python/test_provider_spatialite.py
  12. +1 −1 tests/src/python/test_provider_tabfile.py
  13. +14 −16 tests/src/python/test_provider_virtual.py
  14. +3 −5 tests/src/python/test_qgsanalysis.py
  15. +1 −1 tests/src/python/test_qgsapplication.py
  16. +2 −2 tests/src/python/test_qgsatlascomposition.py
  17. +4 −3 tests/src/python/test_qgsauthsystem.py
  18. +4 −6 tests/src/python/test_qgsblendmodes.py
  19. +3 −5 tests/src/python/test_qgscategorizedsymbolrendererv2.py
  20. +2 −2 tests/src/python/test_qgscolorscheme.py
  21. +1 −1 tests/src/python/test_qgscolorschemeregistry.py
  22. +3 −5 tests/src/python/test_qgscomposereffects.py
  23. +4 −9 tests/src/python/test_qgscomposerhtml.py
  24. +2 −2 tests/src/python/test_qgscomposerlabel.py
  25. +5 −7 tests/src/python/test_qgscomposermap.py
  26. +3 −5 tests/src/python/test_qgscomposermapgrid.py
  27. +3 −5 tests/src/python/test_qgscomposerpicture.py
  28. +3 −5 tests/src/python/test_qgscomposershapes.py
  29. +4 −8 tests/src/python/test_qgscomposition.py
  30. +1 −1 tests/src/python/test_qgsconditionalstyle.py
  31. +1 −1 tests/src/python/test_qgscoordinatetransform.py
  32. +5 −16 tests/src/python/test_qgsdelimitedtextprovider.py
  33. +3 −5 tests/src/python/test_qgsdistancearea.py
  34. +2 −5 tests/src/python/test_qgseditwidgets.py
  35. +1 −1 tests/src/python/test_qgsexpression.py
  36. +1 −1 tests/src/python/test_qgsfeature.py
  37. +2 −4 tests/src/python/test_qgsfeatureiterator.py
  38. +2 −4 tests/src/python/test_qgsfield.py
  39. +1 −1 tests/src/python/test_qgsgeometry_avoid_intersections.py
  40. +3 −8 tests/src/python/test_qgsgeometrygeneratorsymbollayerv2.py
  41. +5 −7 tests/src/python/test_qgsgraduatedsymbolrendererv2.py
  42. +3 −5 tests/src/python/test_qgsissue7244.py
  43. +3 −6 tests/src/python/test_qgslayerdefinition.py
  44. +1 −1 tests/src/python/test_qgslogger.py
  45. +2 −2 tests/src/python/test_qgsmapunitscale.py
  46. +3 −3 tests/src/python/test_qgsnetworkcontentfetcher.py
  47. +4 −8 tests/src/python/test_qgspallabeling_base.py
  48. +2 −2 tests/src/python/test_qgspallabeling_canvas.py
  49. +5 −4 tests/src/python/test_qgspallabeling_composer.py
  50. +3 −8 tests/src/python/test_qgspallabeling_placement.py
  51. +2 −2 tests/src/python/test_qgspallabeling_server.py
  52. +3 −3 tests/src/python/test_qgspallabeling_tests.py
  53. +1 −1 tests/src/python/test_qgspoint.py
  54. +1 −1 tests/src/python/test_qgsproject.py
  55. +4 −8 tests/src/python/test_qgsrangewidgets.py
  56. +4 −7 tests/src/python/test_qgsrasterfilewriter.py
  57. +4 −6 tests/src/python/test_qgsrasterlayer.py
  58. +3 −9 tests/src/python/test_qgsrectangle.py
  59. +2 −4 tests/src/python/test_qgsrelation.py
  60. +9 −23 tests/src/python/test_qgsrelationeditwidget.py
  61. +4 −7 tests/src/python/test_qgsrulebasedrenderer.py
  62. +3 −3 tests/src/python/test_qgsserver_accesscontrol.py
  63. +3 −7 tests/src/python/test_qgssinglesymbolrenderer.py
  64. +5 −5 tests/src/python/test_qgssipcoverage.py
  65. +2 −4 tests/src/python/test_qgsspatialindex.py
  66. +3 −7 tests/src/python/test_qgssymbolexpressionvariables.py
  67. +6 −7 tests/src/python/test_qgssymbollayerv2.py
  68. +6 −9 tests/src/python/test_qgssymbolv2.py
  69. +2 −2 tests/src/python/test_qgsunittypes.py
  70. +3 −3 tests/src/python/test_qgsvectorcolorramp.py
  71. +4 −11 tests/src/python/test_qgsvectorfilewriter.py
  72. +11 −13 tests/src/python/test_qgsvectorlayer.py
  73. +2 −3 tests/src/python/test_qgsvirtuallayerdefinition.py
  74. +2 −6 tests/src/python/test_qgszonalstatistics.py
  75. +3 −5 tests/src/python/test_syntactic_sugar.py
  76. +4 −4 tests/src/python/utilities.py
@@ -25,7 +25,7 @@

__revision__ = ':%H$'

from . import AlgorithmsTestBase
import AlgorithmsTestBase

import nose2
import shutil
@@ -25,7 +25,7 @@

__revision__ = ':%H$'

from . import AlgorithmsTestBase
import AlgorithmsTestBase

import nose2
import shutil
@@ -30,7 +30,7 @@
import difflib
import functools

from PyQt4.QtCore import QVariant
from PyQt.QtCore import QVariant
from qgis.core import QgsApplication, QgsFeatureRequest, QgsVectorLayer
from nose2.compat import unittest

@@ -32,8 +32,8 @@
from qgis.gui import QgisInterface, QgsMapCanvas
from qgis.core import QgsApplication

from PyQt4.QtGui import QMainWindow
from PyQt4.QtCore import QSize
from PyQt.QtWidgets import QMainWindow
from PyQt.QtCore import QSize

from qgis.testing import start_app

@@ -24,7 +24,7 @@
'Copyright (c) 2011 German Carrillo, '
'geotux_tuxman@linuxmail.org')

import qgis # switch sip api
import qgis # NOQA
from PyQt.QtCore import QObject
from qgis.core import QgsMapLayerRegistry

@@ -15,10 +15,10 @@
***************************************************************************/
'''

import qgis # switch sip api
import qgis # NOQA

from PyQt4.QtCore import QSize, QDir, QFileInfo
from PyQt4.QtGui import QImage, QPainter
from PyQt.QtCore import QSize, QDir, QFileInfo
from PyQt.QtGui import QImage, QPainter
from qgis.core import QgsMultiRenderChecker, QgsComposition


@@ -36,7 +36,7 @@
)

from providertestbase import ProviderTestCase
from PyQt4.QtCore import QVariant
from PyQt.QtCore import QVariant

start_app()
TEST_DATA_DIR = unitTestDataPath()
@@ -12,28 +12,16 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # switch sip api
import qgis # NOQA

import os

from qgis.core import (
QgsVectorLayer,
QgsFeatureRequest,
)
from qgis.core import QgsVectorLayer, QgsFeatureRequest

from PyQt4.QtCore import (
QSettings,
QDate,
QTime,
QDateTime,
QVariant
)
from PyQt.QtCore import QSettings, QDate, QTime, QDateTime, QVariant

from utilities import unitTestDataPath
from qgis.testing import (
start_app,
unittest
)
from qgis.testing import start_app, unittest
from providertestbase import ProviderTestCase

start_app()
@@ -12,16 +12,14 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # switch sip api
import qgis # NOQA

import os
from qgis.core import NULL

from qgis.core import QgsVectorLayer, QgsFeatureRequest
from PyQt4.QtCore import QSettings, QDate, QTime, QDateTime, QVariant
from qgis.testing import (start_app,
unittest
)
from PyQt.QtCore import QSettings, QDate, QTime, QDateTime, QVariant
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath
from providertestbase import ProviderTestCase

@@ -12,18 +12,16 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # switch sip api
import qgis # NOQA

import os
import tempfile
import shutil
import glob

from qgis.core import QgsVectorLayer, QgsFeatureRequest
from PyQt4.QtCore import QSettings
from qgis.testing import (start_app,
unittest
)
from PyQt.QtCore import QSettings
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath
from providertestbase import ProviderTestCase

@@ -12,19 +12,17 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # switch sip api
import qgis # NOQA

import os
import tempfile

from qgis.core import QgsVectorLayer, QgsPoint, QgsFeature

from qgis.testing import (start_app,
unittest
)
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath
from providertestbase import ProviderTestCase
from PyQt4.QtCore import QSettings
from PyQt.QtCore import QSettings

try:
from pyspatialite import dbapi2 as sqlite3
@@ -176,8 +174,8 @@ def test_queries(self):
sum_id1 = sum(f.id() for f in l.getFeatures())
# the attribute 'id' works
sum_id2 = sum(f.attributes()[0] for f in l.getFeatures())
assert(sum_id1 == 3) # 1+2
assert(sum_id2 == 32) # 11 + 21
assert(sum_id1 == 3) # 1+2
assert(sum_id2 == 32) # 11 + 21

# and now with an id declared
l = QgsVectorLayer("dbname=%s table='(select * from test_q)' (geometry) key='id'" % self.dbname, "test_pg_query1", "spatialite")
@@ -15,7 +15,7 @@
import os

from qgis.core import QgsVectorLayer, QgsFeatureRequest
from PyQt4.QtCore import QDate, QTime, QDateTime, QVariant
from PyQt.QtCore import QDate, QTime, QDateTime, QVariant
from qgis.testing import (
start_app,
unittest
@@ -12,7 +12,7 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # switch sip api
import qgis # NOQA
import os

from qgis.core import (QgsVectorLayer,
@@ -26,13 +26,11 @@
QgsProject
)

from qgis.testing import (start_app,
unittest
)
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath

from providertestbase import ProviderTestCase
from PyQt4.QtCore import QUrl, QVariant
from PyQt.QtCore import QUrl, QVariant

try:
from pyspatialite import dbapi2 as sqlite3
@@ -217,7 +215,7 @@ def test_Query(self):
query = QUrl.toPercentEncoding("SELECT * FROM ww")
l2 = QgsVectorLayer("?layer_ref=%s:ww&query=%s&uid=ObJeCtId&nogeometry" % (l1.id(), query), "vtab", "virtual", False)
self.assertEqual(l2.isValid(), True)
self.assertEqual(l2.dataProvider().geometryType(), 100) # NoGeometry
self.assertEqual(l2.dataProvider().geometryType(), 100) # NoGeometry
ref_sum2 = sum(f.attributes()[0] for f in l2.getFeatures())
ref_sum3 = sum(f.id() for f in l2.getFeatures())
self.assertEqual(ref_sum, ref_sum2)
@@ -248,7 +246,7 @@ def test_QueryTableName(self):
query = str(QUrl.toPercentEncoding("SELECT * FROM vt"))
l2 = QgsVectorLayer("?layer_ref=%s:vt&query=%s&uid=ObJeCtId&nogeometry" % (l1.id(), query), "vtab", "virtual", False)
self.assertEqual(l2.isValid(), True)
self.assertEqual(l2.dataProvider().geometryType(), 100) # NoGeometry
self.assertEqual(l2.dataProvider().geometryType(), 100) # NoGeometry

QgsMapLayerRegistry.instance().removeMapLayer(l1.id())

@@ -334,7 +332,7 @@ def test_no_geometry(self):
df.setGeometryWkbType(QgsWKBTypes.NoGeometry)
l2 = QgsVectorLayer(df.toString(), "vtab2", "virtual", False)
self.assertEqual(l2.isValid(), True)
self.assertEqual(l2.dataProvider().geometryType(), 100) # NoGeometry
self.assertEqual(l2.dataProvider().geometryType(), 100) # NoGeometry

def test_reopen(self):
source = QUrl.toPercentEncoding(os.path.join(self.testDataDir, "france_parts.shp"))
@@ -414,7 +412,7 @@ def test_refLayers(self):
l2 = QgsVectorLayer("?layer_ref=%s:t%d&query=%s&uid=id" % (l1.id(), i, q), "vtab", "virtual", False)
QgsMapLayerRegistry.instance().addMapLayer(l2)
self.assertEqual(l2.isValid(), True)
s = sum([f.id() for f in l2.dataProvider().getFeatures()])
s = sum([f.id() for f in l2.dataProvider().getFeatures()]) # NOQA
self.assertEqual(sum([f.id() for f in l2.getFeatures()]), 21)
QgsMapLayerRegistry.instance().removeMapLayer(l2.id())

@@ -532,7 +530,7 @@ def test_sql_field_types(self):
self.assertEqual(l4.dataProvider().fields().at(1).type(), QVariant.String)
self.assertEqual(l4.dataProvider().fields().at(2).name(), "t4")
self.assertEqual(l4.dataProvider().fields().at(2).type(), QVariant.Int)
self.assertEqual(l4.dataProvider().geometryType(), 4) # multipoint
self.assertEqual(l4.dataProvider().geometryType(), 4) # multipoint

# test value types (!= from declared column types)
for f in l4.getFeatures():
@@ -544,7 +542,7 @@ def test_sql_field_types(self):
query = QUrl.toPercentEncoding("SELECT 1 as id /*:int*/, geomfromtext('point(0 0)',4326) as geometry/*:point:4326*/")
l4 = QgsVectorLayer("?query=%s&geometry=geometry" % query, "tt", "virtual", False)
self.assertEqual(l4.isValid(), True)
self.assertEqual(l4.dataProvider().geometryType(), 1) # point
self.assertEqual(l4.dataProvider().geometryType(), 1) # point

# with type annotations and url options (2)
query = QUrl.toPercentEncoding("SELECT 1 as id /*:int*/, 3.14 as f, geomfromtext('point(0 0)',4326) as geometry/*:point:4326*/")
@@ -554,7 +552,7 @@ def test_sql_field_types(self):
self.assertEqual(l4.dataProvider().fields().at(0).type(), QVariant.String)
self.assertEqual(l4.dataProvider().fields().at(1).name(), "f")
self.assertEqual(l4.dataProvider().fields().at(1).type(), QVariant.Double)
self.assertEqual(l4.dataProvider().geometryType(), 1) # point
self.assertEqual(l4.dataProvider().geometryType(), 1) # point

def test_sql3b(self):
query = QUrl.toPercentEncoding("SELECT GeomFromText('POINT(0 0)') as geom")
@@ -609,7 +607,7 @@ def test_encoding(self):
l = QgsVectorLayer("?layer=ogr:%s:fp:UTF-8" % source, "vtab", "virtual", False)
self.assertEqual(l.isValid(), True)
for f in l.getFeatures():
self.assertEqual(f.attributes()[1], u"accents \ufffd\ufffd\ufffd") # invalid unicode characters
self.assertEqual(f.attributes()[1], u"accents \ufffd\ufffd\ufffd") # invalid unicode characters

def test_rowid(self):
source = QUrl.toPercentEncoding(os.path.join(self.testDataDir, "france_parts.shp"))
@@ -626,21 +624,21 @@ def test_geometry_conversion(self):
self.assertEqual(l.isValid(), True)
for f in l.getFeatures():
self.assertEqual(f.geometry().exportToWkt().lower().startswith("multipoint"), True)
self.assertEqual("),(" in f.geometry().exportToWkt(), True) # has two points
self.assertEqual("),(" in f.geometry().exportToWkt(), True) # has two points

query = QUrl.toPercentEncoding("select geomfromtext('multipolygon(((0 0,1 0,1 1,0 1,0 0)),((0 1,1 1,1 2,0 2,0 1)))') as geom")
l = QgsVectorLayer("?query=%s&geometry=geom:multipolygon:0" % query, "tt", "virtual", False)
self.assertEqual(l.isValid(), True)
for f in l.getFeatures():
self.assertEqual(f.geometry().exportToWkt().lower().startswith("multipolygon"), True)
self.assertEqual(")),((" in f.geometry().exportToWkt(), True) # has two polygons
self.assertEqual(")),((" in f.geometry().exportToWkt(), True) # has two polygons

query = QUrl.toPercentEncoding("select geomfromtext('multilinestring((0 0,1 0,1 1,0 1,0 0),(0 1,1 1,1 2,0 2,0 1))') as geom")
l = QgsVectorLayer("?query=%s&geometry=geom:multilinestring:0" % query, "tt", "virtual", False)
self.assertEqual(l.isValid(), True)
for f in l.getFeatures():
self.assertEqual(f.geometry().exportToWkt().lower().startswith("multilinestring"), True)
self.assertEqual("),(" in f.geometry().exportToWkt(), True) # has two linestrings
self.assertEqual("),(" in f.geometry().exportToWkt(), True) # has two linestrings

def test_queryOnMemoryLayer(self):
ml = QgsVectorLayer("Point?srid=EPSG:4326&field=a:int", "mem", "memory")
@@ -15,11 +15,9 @@
***************************************************************************/
'''

import qgis # switch sip api
import qgis # NOQA

from qgis.testing import (start_app,
unittest
)
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath

start_app()
@@ -41,7 +39,7 @@ def testSubstitutionMap(self):
"""Test that we can import zonal statistics was failing as of d5f6543
"""
try:
from qgis.analysis import QgsZonalStatistics
from qgis.analysis import QgsZonalStatistics # NOQA
except ImportError:
self.fail('Failed to import zonal statistics python module')

@@ -11,7 +11,7 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # switch sip api
import qgis # NOQA
from qgis.testing import start_app, unittest


@@ -14,14 +14,14 @@
* *
***************************************************************************/
'''
import qgis # switch sip api
import qgis # NOQA
import os
import glob
import shutil
import tempfile
from qgis.testing import start_app, unittest
from utilities import unitTestDataPath
from PyQt4.QtCore import QFileInfo, QRectF, qWarning
from PyQt.QtCore import QFileInfo, QRectF, qWarning
from qgis.core import QGis, QgsVectorLayer, QgsMapLayerRegistry, QgsMapSettings, QgsCoordinateReferenceSystem, \
QgsComposition, QgsFillSymbolV2, QgsSingleSymbolRendererV2, QgsComposerLabel, QgsComposerMap, QgsFontUtils, \
QgsRectangle, QgsComposerLegend, QgsFeature, QgsGeometry, QgsPoint, QgsRendererCategoryV2, QgsCategorizedSymbolRendererV2, QgsMarkerSymbolV2
@@ -21,9 +21,10 @@
from qgis.gui import QgsAuthEditorWidgets


from PyQt4.QtCore import QFileInfo, qDebug, QSsl, QSslError, QSslSocket
from PyQt4.QtGui import QDialog, QVBoxLayout, QDialogButtonBox
from PyQt4.QtTest import QTest
from PyQt.QtCore import QFileInfo, qDebug
from PyQt.QtWidgets import QDialog, QVBoxLayout, QDialogButtonBox
from PyQt.QtTest import QTest
from PyQt.QtNetwork import QSsl, QSslError, QSslSocket

from qgis.testing import (
start_app,
@@ -23,12 +23,12 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # switch sip api
import qgis # NOQA

import os

from PyQt4.QtCore import QSize
from PyQt4.QtGui import QPainter, QColor
from PyQt.QtCore import QSize
from PyQt.QtGui import QPainter, QColor

from qgis.core import (QgsVectorLayer,
QgsVectorSimplifyMethod,
@@ -39,9 +39,7 @@
QgsRectangle
)

from qgis.testing import (start_app,
unittest
)
from qgis.testing import start_app, unittest

from qgis.testing.mocked import get_iface

0 comments on commit f413046

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