@@ -184,6 +184,14 @@ def getSubsetString2(self):
184
184
"""Individual providers may need to override this depending on their subset string formats"""
185
185
return '"cnt" > 100 and "cnt" < 400'
186
186
187
+ def getSubsetString3 (self ):
188
+ """Individual providers may need to override this depending on their subset string formats"""
189
+ return '"name"=\' Apple\' '
190
+
191
+ def getSubsetStringNoMatching (self ):
192
+ """Individual providers may need to override this depending on their subset string formats"""
193
+ return '"name"=\' AppleBearOrangePear\' '
194
+
187
195
def testOrderBy (self ):
188
196
try :
189
197
self .disableCompiler ()
@@ -281,9 +289,30 @@ def testMaxValue(self):
281
289
def testExtent (self ):
282
290
reference = QgsGeometry .fromRect (
283
291
QgsRectangle (- 71.123 , 66.33 , - 65.32 , 78.3 ))
284
- provider_extent = QgsGeometry .fromRect (self .source .extent ())
292
+ provider_extent = self .source .extent ()
293
+ self .assertAlmostEqual (provider_extent .xMinimum (), - 71.123 , 3 )
294
+ self .assertAlmostEqual (provider_extent .xMaximum (), - 65.32 , 3 )
295
+ self .assertAlmostEqual (provider_extent .yMinimum (), 66.33 , 3 )
296
+ self .assertAlmostEqual (provider_extent .yMaximum (), 78.3 , 3 )
297
+
298
+ # with only one point
299
+ subset = self .getSubsetString3 ()
300
+ self .source .setSubsetString (subset )
301
+ self .assertEqual (self .source .featureCount (), 1 )
302
+ provider_extent = self .source .extent ()
303
+ self .source .setSubsetString (None )
304
+ self .assertAlmostEqual (provider_extent .xMinimum (), - 68.2 , 3 )
305
+ self .assertAlmostEqual (provider_extent .xMaximum (), - 68.2 , 3 )
306
+ self .assertAlmostEqual (provider_extent .yMinimum (), 70.8 , 3 )
307
+ self .assertAlmostEqual (provider_extent .yMaximum (), 70.8 , 3 )
285
308
286
- self .assertTrue (QgsGeometry .compare (provider_extent .asPolygon ()[0 ], reference .asPolygon ()[0 ], 0.00001 ))
309
+ # with no points
310
+ subset = self .getSubsetStringNoMatching ()
311
+ self .source .setSubsetString (subset )
312
+ self .assertEqual (self .source .featureCount (), 0 )
313
+ provider_extent = self .source .extent ()
314
+ self .source .setSubsetString (None )
315
+ self .assertTrue (provider_extent .isNull ())
287
316
288
317
def testUnique (self ):
289
318
self .assertEqual (set (self .source .uniqueValues (1 )), set ([- 200 , 100 , 200 , 300 , 400 ]))
0 commit comments