42
42
)
43
43
44
44
from providertestbase import ProviderTestCase
45
- from qgis .PyQt .QtCore import QVariant , QByteArray
45
+ from qgis .PyQt .QtCore import QVariant , QByteArray , QDate , QDateTime , QTime
46
46
47
47
start_app ()
48
48
TEST_DATA_DIR = unitTestDataPath ()
@@ -53,27 +53,27 @@ class TestPyQgsMemoryProvider(unittest.TestCase, ProviderTestCase):
53
53
@classmethod
54
54
def createLayer (cls ):
55
55
vl = QgsVectorLayer (
56
- 'Point?crs=epsg:4326&field=pk:integer&field=cnt:integer&field=name:string(0)&field=name2:string(0)&field=num_char:string&key=pk' ,
56
+ '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' ,
57
57
'test' , 'memory' )
58
58
assert (vl .isValid ())
59
59
60
60
f1 = QgsFeature ()
61
- f1 .setAttributes ([5 , - 200 , NULL , 'NuLl' , '5' ])
61
+ f1 .setAttributes ([5 , - 200 , NULL , 'NuLl' , '5' , QDateTime ( QDate ( 2020 , 5 , 4 ), QTime ( 12 , 13 , 14 )), QDate ( 2020 , 5 , 4 ), QTime ( 12 , 13 , 14 ) ])
62
62
f1 .setGeometry (QgsGeometry .fromWkt ('Point (-71.123 78.23)' ))
63
63
64
64
f2 = QgsFeature ()
65
- f2 .setAttributes ([3 , 300 , 'Pear' , 'PEaR' , '3' ])
65
+ f2 .setAttributes ([3 , 300 , 'Pear' , 'PEaR' , '3' , NULL , NULL , NULL ])
66
66
67
67
f3 = QgsFeature ()
68
- f3 .setAttributes ([1 , 100 , 'Orange' , 'oranGe' , '1' ])
68
+ f3 .setAttributes ([1 , 100 , 'Orange' , 'oranGe' , '1' , QDateTime ( QDate ( 2020 , 5 , 3 ), QTime ( 12 , 13 , 14 )), QDate ( 2020 , 5 , 3 ), QTime ( 12 , 13 , 14 ) ])
69
69
f3 .setGeometry (QgsGeometry .fromWkt ('Point (-70.332 66.33)' ))
70
70
71
71
f4 = QgsFeature ()
72
- f4 .setAttributes ([2 , 200 , 'Apple' , 'Apple' , '2' ])
72
+ f4 .setAttributes ([2 , 200 , 'Apple' , 'Apple' , '2' , QDateTime ( QDate ( 2020 , 5 , 4 ), QTime ( 12 , 14 , 14 )), QDate ( 2020 , 5 , 4 ), QTime ( 12 , 14 , 14 ) ])
73
73
f4 .setGeometry (QgsGeometry .fromWkt ('Point (-68.2 70.8)' ))
74
74
75
75
f5 = QgsFeature ()
76
- f5 .setAttributes ([4 , 400 , 'Honey' , 'Honey' , '4' ])
76
+ f5 .setAttributes ([4 , 400 , 'Honey' , 'Honey' , '4' , QDateTime ( QDate ( 2021 , 5 , 4 ), QTime ( 13 , 13 , 14 )), QDate ( 2021 , 5 , 4 ), QTime ( 13 , 13 , 14 ) ])
77
77
f5 .setGeometry (QgsGeometry .fromWkt ('Point (-65.32 78.3)' ))
78
78
79
79
vl .dataProvider ().addFeatures ([f1 , f2 , f3 , f4 , f5 ])
@@ -687,28 +687,28 @@ def setUpClass(cls):
687
687
"""Run before all tests"""
688
688
# Create test layer
689
689
cls .vl = QgsVectorLayer (
690
- 'Point?crs=epsg:4326&index=yes& field=pk:integer&field=cnt:int8 &field=name:string(0)&field=name2:string(0)&field=num_char:string&key=pk' ,
690
+ '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' ,
691
691
'test' , 'memory' )
692
692
assert (cls .vl .isValid ())
693
693
cls .source = cls .vl .dataProvider ()
694
694
695
695
f1 = QgsFeature ()
696
- f1 .setAttributes ([5 , - 200 , NULL , 'NuLl' , '5' ])
696
+ f1 .setAttributes ([5 , - 200 , NULL , 'NuLl' , '5' , QDateTime ( QDate ( 2020 , 5 , 4 ), QTime ( 12 , 13 , 14 )), QDate ( 2020 , 5 , 4 ), QTime ( 12 , 13 , 14 ) ])
697
697
f1 .setGeometry (QgsGeometry .fromWkt ('Point (-71.123 78.23)' ))
698
698
699
699
f2 = QgsFeature ()
700
- f2 .setAttributes ([3 , 300 , 'Pear' , 'PEaR' , '3' ])
700
+ f2 .setAttributes ([3 , 300 , 'Pear' , 'PEaR' , '3' , NULL , NULL , NULL ])
701
701
702
702
f3 = QgsFeature ()
703
- f3 .setAttributes ([1 , 100 , 'Orange' , 'oranGe' , '1' ])
703
+ f3 .setAttributes ([1 , 100 , 'Orange' , 'oranGe' , '1' , QDateTime ( QDate ( 2020 , 5 , 3 ), QTime ( 12 , 13 , 14 )), QDate ( 2020 , 5 , 3 ), QTime ( 12 , 13 , 14 ) ])
704
704
f3 .setGeometry (QgsGeometry .fromWkt ('Point (-70.332 66.33)' ))
705
705
706
706
f4 = QgsFeature ()
707
- f4 .setAttributes ([2 , 200 , 'Apple' , 'Apple' , '2' ])
707
+ f4 .setAttributes ([2 , 200 , 'Apple' , 'Apple' , '2' , QDateTime ( QDate ( 2020 , 5 , 4 ), QTime ( 12 , 14 , 14 )), QDate ( 2020 , 5 , 4 ), QTime ( 12 , 14 , 14 ) ])
708
708
f4 .setGeometry (QgsGeometry .fromWkt ('Point (-68.2 70.8)' ))
709
709
710
710
f5 = QgsFeature ()
711
- f5 .setAttributes ([4 , 400 , 'Honey' , 'Honey' , '4' ])
711
+ f5 .setAttributes ([4 , 400 , 'Honey' , 'Honey' , '4' , QDateTime ( QDate ( 2021 , 5 , 4 ), QTime ( 13 , 13 , 14 )), QDate ( 2021 , 5 , 4 ), QTime ( 13 , 13 , 14 ) ])
712
712
f5 .setGeometry (QgsGeometry .fromWkt ('Point (-65.32 78.3)' ))
713
713
714
714
cls .source .addFeatures ([f1 , f2 , f3 , f4 , f5 ])
0 commit comments