Skip to content

Commit

Permalink
In place test POC completed
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Sep 14, 2018
1 parent f35e376 commit ac55ce0
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions tests/src/python/test_qgsprocessinginplace.py
Expand Up @@ -58,20 +58,31 @@ def test_algs(self):
parameters = {}
parameters['INPUT'] = QgsProcessingFeatureSourceDefinition(self.vl.id(), True)
parameters['OUTPUT'] = 'memory:'
parameters['DELTA_X'] = 1.1
parameters['DELTA_Y'] = 1.1

context = QgsProcessingContext()
feedback = QgsProcessingFeedback()
self.assertTrue(alg.prepare(parameters, context, feedback))

self.assertTrue(self.vl.startEditing())

field_idxs = range(len(self.vl.fields()))

new_features = {}
for f in self.vl.getFeatures():
new_f = alg.processFeature(f, context, feedback)[0]
new_features[f.id()] = new_f
self.assertEqual(new_f.id(), f.id())
# This alg does change the geometry!
self.vl.changeGeometry(f.id(), new_f.geometry())
# This alg does not change attrs but some other might do
self.vl.changeAttributeValues(f.id(), dict(zip(field_idxs, new_f.attributes())), dict(zip(field_idxs, f.attributes())))

from IPython import embed; embed()



self.assertTrue(self.vl.commitChanges())

for f in self.vl.getFeatures():
self.assertEqual(new_features[f.id()].geometry().asWkt(), f.geometry().asWkt())


if __name__ == '__main__':
Expand Down

0 comments on commit ac55ce0

Please sign in to comment.