Skip to content
Permalink
Browse files

Added multiple edit and attributes tests

  • Loading branch information
elpaso committed Jun 29, 2016
1 parent 009fbc6 commit b819f2baa86f86610017540702e45eb61b03c0b8
@@ -187,6 +187,7 @@ def _checkUpdateFeatures(self, wfs_layer, old_features, new_features):
f = self._getFeatureByAttribute(wfs_layer, 'id', old_features[i]['id'])
self.assertTrue(wfs_layer.dataProvider().changeGeometryValues({f.id(): new_features[i].geometry()}))
self.assertTrue(wfs_layer.dataProvider().changeAttributeValues({f.id(): {0: new_features[i]['id']}}))
self.assertTrue(wfs_layer.dataProvider().changeAttributeValues({f.id(): {1: new_features[i]['name']}}))

def _checkMatchFeatures(self, wfs_layer, features):
"""
@@ -196,6 +197,7 @@ def _checkMatchFeatures(self, wfs_layer, features):
wf = self._getFeatureByAttribute(wfs_layer, 'id', f['id'])
self.assertEqual(wf.geometry().exportToWkt(),
f.geometry().exportToWkt())
self.assertEqual(f['name'], wf['name'])

def _checkDeleteFeatures(self, layer, features):
"""
@@ -242,6 +244,35 @@ def testWFSPoints(self):
new_features = [new_feat1, feat2]
self._testLayer(wfs_layer, layer, old_features, new_features)

def testWFSPointsMultipleEdits(self):
"""
Adds some points, then check.
Modify 2 points, then checks and clear all
"""
layer_name = 'test_point'
layer = self._getLayer(layer_name)
wfs_layer = self._getWFSLayer(layer_name)
feat1 = QgsFeature(wfs_layer.pendingFields())
feat1['id'] = 11
feat1['name'] = 'name 11'
feat1.setGeometry(QgsGeometry.fromPoint(QgsPoint(9, 45)))
feat2 = QgsFeature(wfs_layer.pendingFields())
feat2.setGeometry(QgsGeometry.fromPoint(QgsPoint(9.5, 45.5)))
feat2['id'] = 12
feat2['name'] = 'name 12'
old_features = [feat1, feat2]
# Change feat1 and feat2
new_feat1 = QgsFeature(wfs_layer.pendingFields())
new_feat1['id'] = 121
new_feat1['name'] = 'name 121'
new_feat1.setGeometry(QgsGeometry.fromPoint(QgsPoint(10, 46)))
new_feat2 = QgsFeature(wfs_layer.pendingFields())
new_feat2['id'] = 122
new_feat2['name'] = 'name 122'
new_feat2.setGeometry(QgsGeometry.fromPoint(QgsPoint(10.5, 47)))
new_features = [new_feat1, new_feat2]
self._testLayer(wfs_layer, layer, old_features, new_features)

def testWFSPolygons(self):
"""
Adds some polygons, then check and clear all
@@ -251,14 +282,17 @@ def testWFSPolygons(self):
wfs_layer = self._getWFSLayer(layer_name)
feat1 = QgsFeature(wfs_layer.pendingFields())
feat1['id'] = 11
feat1['name'] = 'name 11'
feat1.setGeometry(QgsGeometry.fromRect(QgsRectangle(QgsPoint(9, 45), QgsPoint(10, 46))))
feat2 = QgsFeature(wfs_layer.pendingFields())
feat2.setGeometry(QgsGeometry.fromRect(QgsRectangle(QgsPoint(9.5, 45.5), QgsPoint(10.5, 46.5))))
feat2['id'] = 12
feat2['name'] = 'name 12'
old_features = [feat1, feat2]
# Change feat1
new_feat1 = QgsFeature(wfs_layer.pendingFields())
new_feat1['id'] = 121
new_feat1['name'] = 'name 121'
new_feat1.setGeometry(QgsGeometry.fromRect(QgsRectangle(QgsPoint(10, 46), QgsPoint(11.5, 47.5))))
new_features = [new_feat1, feat2]
self._testLayer(wfs_layer, layer, old_features, new_features)
@@ -272,14 +306,17 @@ def testWFSLineStrings(self):
wfs_layer = self._getWFSLayer(layer_name)
feat1 = QgsFeature(wfs_layer.pendingFields())
feat1['id'] = 11
feat1['name'] = 'name 11'
feat1.setGeometry(QgsGeometry.fromPolyline([QgsPoint(9, 45), QgsPoint(10, 46)]))
feat2 = QgsFeature(wfs_layer.pendingFields())
feat2.setGeometry(QgsGeometry.fromPolyline([QgsPoint(9.5, 45.5), QgsPoint(10.5, 46.5)]))
feat2['id'] = 12
feat2['name'] = 'name 12'
old_features = [feat1, feat2]
# Change feat1
new_feat1 = QgsFeature(wfs_layer.pendingFields())
new_feat1['id'] = 121
new_feat1['name'] = 'name 121'
new_feat1.setGeometry(QgsGeometry.fromPolyline([QgsPoint(9.8, 45.8), QgsPoint(10.8, 46.8)]))
new_features = [new_feat1, feat2]
self._testLayer(wfs_layer, layer, old_features, new_features)
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,6 @@
<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis projectname="QGIS Test Project" version="2.15.0-Master">
<qgis projectname="QGIS Test Project" version="2.14.3-Essen">
<title>QGIS Test Project</title>
<autotransaction active="0"/>
<layer-tree-group expanded="1" checked="Qt::Checked" name="">
<customproperties/>
<layer-tree-layer expanded="1" checked="Qt::Checked" id="test_polygon20160506144729957" name="test_polygon">
@@ -76,7 +75,7 @@
</legendlayer>
</legend>
<projectlayers>
<maplayer minimumScale="0" maximumScale="1e+08" simplifyDrawingHints="1" readOnly="0" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Line" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="0" simplifyLocal="0" scaleBasedLabelVisibilityFlag="0">
<maplayer minimumScale="0" maximumScale="1e+08" simplifyDrawingHints="1" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Line" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="0" simplifyLocal="0" scaleBasedLabelVisibilityFlag="0">
<id>test_linestring20160506144729962</id>
<datasource>./test_linestring.shp</datasource>
<keywordList>
@@ -96,7 +95,7 @@
</spatialrefsys>
</srs>
<provider encoding="System">ogr</provider>
<previewExpression></previewExpression>
<previewExpression>COALESCE( "id", '&lt;NULL>' )</previewExpression>
<vectorjoins/>
<layerDependencies/>
<expressionfields/>
@@ -107,6 +106,9 @@
<edittype widgetv2type="TextEdit" name="id">
<widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
</edittype>
<edittype widgetv2type="TextEdit" name="name">
<widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
</edittype>
</edittypes>
<renderer-v2 forceraster="0" symbollevels="0" type="singleSymbol" enableorderby="0">
<symbols>
@@ -172,15 +174,12 @@
<featformsuppress>0</featformsuppress>
<editorlayout>generatedlayout</editorlayout>
<widgets/>
<attributetableconfig actionWidgetStyle="dropDown">
<columns/>
</attributetableconfig>
<conditionalstyles>
<rowstyles/>
<fieldstyles/>
</conditionalstyles>
</maplayer>
<maplayer minimumScale="0" maximumScale="1e+08" simplifyDrawingHints="1" readOnly="0" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Point" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="0" simplifyLocal="0" scaleBasedLabelVisibilityFlag="0">
<maplayer minimumScale="0" maximumScale="1e+08" simplifyDrawingHints="1" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Point" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="0" simplifyLocal="0" scaleBasedLabelVisibilityFlag="0">
<id>test_point20160506204349847</id>
<datasource>./test_point.shp</datasource>
<keywordList>
@@ -211,6 +210,9 @@
<edittype widgetv2type="TextEdit" name="id">
<widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
</edittype>
<edittype widgetv2type="TextEdit" name="name">
<widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
</edittype>
</edittypes>
<renderer-v2 forceraster="0" symbollevels="0" type="singleSymbol" enableorderby="0">
<symbols>
@@ -219,7 +221,6 @@
<prop k="angle" v="0"/>
<prop k="color" v="172,87,41,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="joinstyle" v="bevel"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0,0,0,0,0"/>
@@ -279,15 +280,12 @@
<featformsuppress>0</featformsuppress>
<editorlayout>generatedlayout</editorlayout>
<widgets/>
<attributetableconfig actionWidgetStyle="dropDown">
<columns/>
</attributetableconfig>
<conditionalstyles>
<rowstyles/>
<fieldstyles/>
</conditionalstyles>
</maplayer>
<maplayer minimumScale="0" maximumScale="1e+08" simplifyDrawingHints="1" readOnly="0" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Polygon" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="0" simplifyLocal="0" scaleBasedLabelVisibilityFlag="0">
<maplayer minimumScale="0" maximumScale="1e+08" simplifyDrawingHints="1" minLabelScale="0" maxLabelScale="1e+08" simplifyDrawingTol="1" geometry="Polygon" simplifyMaxScale="1" type="vector" hasScaleBasedVisibilityFlag="0" simplifyLocal="0" scaleBasedLabelVisibilityFlag="0">
<id>test_polygon20160506144729957</id>
<datasource>./test_polygon.shp</datasource>
<keywordList>
@@ -307,7 +305,7 @@
</spatialrefsys>
</srs>
<provider encoding="System">ogr</provider>
<previewExpression></previewExpression>
<previewExpression>COALESCE( "id", '&lt;NULL>' )</previewExpression>
<vectorjoins/>
<layerDependencies/>
<expressionfields/>
@@ -318,6 +316,9 @@
<edittype widgetv2type="TextEdit" name="id">
<widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
</edittype>
<edittype widgetv2type="TextEdit" name="name">
<widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
</edittype>
</edittypes>
<renderer-v2 forceraster="0" symbollevels="0" type="singleSymbol" enableorderby="0">
<symbols>
@@ -379,9 +380,6 @@
<featformsuppress>0</featformsuppress>
<editorlayout>generatedlayout</editorlayout>
<widgets/>
<attributetableconfig actionWidgetStyle="dropDown">
<columns/>
</attributetableconfig>
<conditionalstyles>
<rowstyles/>
<fieldstyles/>
@@ -400,15 +398,15 @@
<DistanceUnits type="QString">meters</DistanceUnits>
<AreaUnits type="QString">m2</AreaUnits>
</Measurement>
<Legend>
<filterByMap type="bool">false</filterByMap>
</Legend>
<WMSExtent type="QStringList">
<value>8.20315414376310059</value>
<value>44.901236559338642</value>
<value>8.204164917965862</value>
<value>44.90159838674664172</value>
</WMSExtent>
<Legend>
<filterByMap type="bool">false</filterByMap>
</Legend>
<DefaultStyles>
<Fill type="QString"></Fill>
<Line type="QString"></Line>
@@ -514,15 +512,15 @@
<SelectionColorGreenPart type="int">255</SelectionColorGreenPart>
<CanvasColorBluePart type="int">255</CanvasColorBluePart>
</Gui>
<Measure>
<Ellipsoid type="QString">WGS84</Ellipsoid>
</Measure>
<WMSServiceAbstract type="QString">Some UTF8 text èòù</WMSServiceAbstract>
<WFSLayers type="QStringList">
<value>test_linestring20160506144729962</value>
<value>test_point20160506204349847</value>
<value>test_polygon20160506144729957</value>
</WFSLayers>
<WMSServiceAbstract type="QString">Some UTF8 text èòù</WMSServiceAbstract>
<Measure>
<Ellipsoid type="QString">WGS84</Ellipsoid>
</Measure>
<WFSUrl type="QString"></WFSUrl>
<WMSServiceCapabilities type="bool">true</WMSServiceCapabilities>
<WMSUseLayerIDs type="bool">false</WMSUseLayerIDs>

0 comments on commit b819f2b

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