Skip to content

Commit

Permalink
Another test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 14, 2020
1 parent 8205eae commit 338f792
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions tests/src/python/test_qgsvectorlayerselectedfeaturesource.py
Expand Up @@ -20,6 +20,8 @@
QgsVectorLayerSelectedFeatureSource
)

from qgis.PyQt.QtCore import QDateTime, QDate, QTime

from qgis.testing import (
start_app,
unittest
Expand All @@ -40,46 +42,46 @@ class TestPyQgsVectorLayerSelectedFeatureSource(unittest.TestCase, FeatureSource
@classmethod
def createLayer(cls):
vl = QgsVectorLayer(
'Point?crs=epsg:4326&field=pk:integer&field=cnt:integer&field=name:string(0)&field=name2:string(0)&field=num_char:string&key=pk',
'Point?crs=epsg:4326&field=pk:integer&field=cnt:integer&field=name:string(0)&field=name2:string(0)&field=num_char:string&field=dt:datetime&field=date:date&field=time:time&key=pk',
'test', 'memory')
assert (vl.isValid())

f1 = QgsFeature()
f1.setAttributes([5, -200, NULL, 'NuLl', '5'])
f1.setAttributes([5, -200, NULL, 'NuLl', '5', QDateTime(QDate(2020, 5, 4), QTime(12, 13, 14)), QDate(2020, 5, 2), QTime(12, 13, 1)])
f1.setGeometry(QgsGeometry.fromWkt('Point (-71.123 78.23)'))

f2 = QgsFeature()
f2.setAttributes([3, 300, 'Pear', 'PEaR', '3'])
f2.setAttributes([3, 300, 'Pear', 'PEaR', '3', NULL, NULL, NULL])

f3 = QgsFeature()
f3.setAttributes([1, 100, 'Orange', 'oranGe', '1'])
f3.setAttributes([1, 100, 'Orange', 'oranGe', '1', QDateTime(QDate(2020, 5, 3), QTime(12, 13, 14)), QDate(2020, 5, 3), QTime(12, 13, 14)])
f3.setGeometry(QgsGeometry.fromWkt('Point (-70.332 66.33)'))

f4 = QgsFeature()
f4.setAttributes([2, 200, 'Apple', 'Apple', '2'])
f4.setAttributes([2, 200, 'Apple', 'Apple', '2', QDateTime(QDate(2020, 5, 4), QTime(12, 14, 14)), QDate(2020, 5, 4), QTime(12, 14, 14)])
f4.setGeometry(QgsGeometry.fromWkt('Point (-68.2 70.8)'))

f5 = QgsFeature()
f5.setAttributes([4, 400, 'Honey', 'Honey', '4'])
f5.setAttributes([4, 400, 'Honey', 'Honey', '4', QDateTime(QDate(2021, 5, 4), QTime(13, 13, 14)), QDate(2021, 5, 4), QTime(13, 13, 14)])
f5.setGeometry(QgsGeometry.fromWkt('Point (-65.32 78.3)'))

f6 = QgsFeature()
f6.setAttributes([6, -200, NULL, 'NuLl', '5'])
f6.setAttributes([6, -200, NULL, 'NuLl', '5', NULL, NULL, NULL])
f6.setGeometry(QgsGeometry.fromWkt('Point (-71.123 78.23)'))

f7 = QgsFeature()
f7.setAttributes([7, 300, 'Pear', 'PEaR', '3'])
f7.setAttributes([7, 300, 'Pear', 'PEaR', '3', NULL, NULL, NULL])

f8 = QgsFeature()
f8.setAttributes([8, 100, 'Orange', 'oranGe', '1'])
f8.setAttributes([8, 100, 'Orange', 'oranGe', '1', NULL, NULL, NULL])
f8.setGeometry(QgsGeometry.fromWkt('Point (-70.332 66.33)'))

f9 = QgsFeature()
f9.setAttributes([9, 200, 'Apple', 'Apple', '2'])
f9.setAttributes([9, 200, 'Apple', 'Apple', '2', NULL, NULL, NULL])
f9.setGeometry(QgsGeometry.fromWkt('Point (-68.2 70.8)'))

f10 = QgsFeature()
f10.setAttributes([10, 400, 'Honey', 'Honey', '4'])
f10.setAttributes([10, 400, 'Honey', 'Honey', '4', NULL, NULL, NULL])
f10.setGeometry(QgsGeometry.fromWkt('Point (-65.32 78.3)'))

vl.dataProvider().addFeatures([f1, f2, f3, f4, f5, f6, f7, f8, f9, f10])
Expand Down

0 comments on commit 338f792

Please sign in to comment.