58
58
from provider_python import PyProvider
59
59
60
60
from providertestbase import ProviderTestCase
61
- from qgis .PyQt .QtCore import QVariant
61
+ from qgis .PyQt .QtCore import QVariant , QDateTime , QDate , QTime
62
62
63
63
start_app ()
64
64
TEST_DATA_DIR = unitTestDataPath ()
@@ -69,27 +69,27 @@ class TestPyQgsPythonProvider(unittest.TestCase, ProviderTestCase):
69
69
@classmethod
70
70
def createLayer (cls ):
71
71
vl = QgsVectorLayer (
72
- 'Point?crs=epsg:4326&field=pk:integer&field=cnt:integer&field=name:string(0)&field=name2:string(0)&field=num_char:string&key=pk' ,
72
+ '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' ,
73
73
'test' , 'pythonprovider' )
74
74
assert (vl .isValid ())
75
75
76
76
f1 = QgsFeature ()
77
- f1 .setAttributes ([5 , - 200 , NULL , 'NuLl' , '5' ])
77
+ f1 .setAttributes ([5 , - 200 , NULL , 'NuLl' , '5' , QDateTime ( QDate ( 2020 , 5 , 4 ), QTime ( 12 , 13 , 14 )), QDate ( 2020 , 5 , 2 ), QTime ( 12 , 13 , 1 ) ])
78
78
f1 .setGeometry (QgsGeometry .fromWkt ('Point (-71.123 78.23)' ))
79
79
80
80
f2 = QgsFeature ()
81
- f2 .setAttributes ([3 , 300 , 'Pear' , 'PEaR' , '3' ])
81
+ f2 .setAttributes ([3 , 300 , 'Pear' , 'PEaR' , '3' , NULL , NULL , NULL ])
82
82
83
83
f3 = QgsFeature ()
84
- f3 .setAttributes ([1 , 100 , 'Orange' , 'oranGe' , '1' ])
84
+ f3 .setAttributes ([1 , 100 , 'Orange' , 'oranGe' , '1' , QDateTime ( QDate ( 2020 , 5 , 3 ), QTime ( 12 , 13 , 14 )), QDate ( 2020 , 5 , 3 ), QTime ( 12 , 13 , 14 ) ])
85
85
f3 .setGeometry (QgsGeometry .fromWkt ('Point (-70.332 66.33)' ))
86
86
87
87
f4 = QgsFeature ()
88
- f4 .setAttributes ([2 , 200 , 'Apple' , 'Apple' , '2' ])
88
+ f4 .setAttributes ([2 , 200 , 'Apple' , 'Apple' , '2' , QDateTime ( QDate ( 2020 , 5 , 4 ), QTime ( 12 , 14 , 14 )), QDate ( 2020 , 5 , 4 ), QTime ( 12 , 14 , 14 ) ])
89
89
f4 .setGeometry (QgsGeometry .fromWkt ('Point (-68.2 70.8)' ))
90
90
91
91
f5 = QgsFeature ()
92
- f5 .setAttributes ([4 , 400 , 'Honey' , 'Honey' , '4' ])
92
+ f5 .setAttributes ([4 , 400 , 'Honey' , 'Honey' , '4' , QDateTime ( QDate ( 2021 , 5 , 4 ), QTime ( 13 , 13 , 14 )), QDate ( 2021 , 5 , 4 ), QTime ( 13 , 13 , 14 ) ])
93
93
f5 .setGeometry (QgsGeometry .fromWkt ('Point (-65.32 78.3)' ))
94
94
95
95
vl .dataProvider ().addFeatures ([f1 , f2 , f3 , f4 , f5 ])
0 commit comments