Skip to content
Permalink
Browse files

Add provider order by tests where expression compilation will fail

  • Loading branch information
nyalldawson committed Dec 20, 2015
1 parent d31e610 commit f24105968da7056e079f7163f9163b9876a9b04a
Showing with 20 additions and 0 deletions.
  1. +20 −0 tests/src/python/providertestbase.py
@@ -160,11 +160,31 @@ def testOrderBy(self):
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4, 3, 2, 1])

# Type dependant expression
request = QgsFeatureRequest().addOrderBy('num_char*2', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4, 3, 2, 1])

# Order by guaranteed to fail
request = QgsFeatureRequest().addOrderBy('not a valid expression*', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(set(values), set([5, 4, 3, 2, 1]))

# Multiple order bys and boolean
request = QgsFeatureRequest().addOrderBy('pk > 2').addOrderBy('pk', False)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [2, 1, 5, 4, 3])

# Multiple order bys, one bad, and a limit
request = QgsFeatureRequest().addOrderBy('pk', False).addOrderBy('not a valid expression*', False).setLimit(2)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4])

# Bad expression first
request = QgsFeatureRequest().addOrderBy('not a valid expression*', False).addOrderBy('pk', False).setLimit(2)
values = [f['pk'] for f in self.provider.getFeatures(request)]
self.assertEquals(values, [5, 4])

def testGetFeaturesFidTests(self):
fids = [f.id() for f in self.provider.getFeatures()]
assert len(fids) == 5, 'Expected 5 features, got {} instead'.format(len(fids))

0 comments on commit f241059

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