Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
domi4484 authored and github-actions[bot] committed Nov 18, 2022
1 parent 77bceff commit e3c5330
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions tests/src/python/test_qgsattributeform.py
Expand Up @@ -16,21 +16,19 @@

from qgis.testing import start_app, unittest
from qgis.core import (
QgsFields,
QgsVectorLayer,
QgsFeature,
QgsEditorWidgetSetup,
QgsEditFormConfig,
QgsAttributeEditorElement,
QgsDefaultValue,
QgsField
)
from qgis.gui import (
QgsAttributeForm,
QgsGui,
QgsEditorWidgetWrapper,
QgsMapCanvas,
QgsAttributeEditorContext
QgsAttributeEditorContext,
QgsFilterLineEdit
)
from qgis.PyQt.QtCore import QVariant

Expand Down Expand Up @@ -119,6 +117,46 @@ def test_duplicated_widgets(self):
for field_type, value in field_types.items():
self.checkForm(field_type, value)

def test_duplicated_widgets_multiedit(self):
"""
Test multiedit whith duplicated widgets
"""

field_type = 'integer'
vl = self.createLayerWithOnePoint(field_type)

# add another point
pr = vl.dataProvider()
f = QgsFeature()
assert pr.addFeatures([f])
assert vl.featureCount() == 2

assert vl.startEditing()

assert vl.changeAttributeValue(1, 0, 123)
assert vl.changeAttributeValue(2, 0, 456)

widget_type = 'TextEdit'
form = self.createFormWithDuplicateWidget(vl, field_type, widget_type)

fids = list()
for feature in vl.getFeatures():
fids.append(feature.id())

form.setMode(QgsAttributeEditorContext.MultiEditMode)
form.setMultiEditFeatureIds(fids)

for children in form.findChildren(QgsFilterLineEdit):
if children.objectName() == 'fld':
# As the values are mixed, the widget values should be empty
assert not children.text()

# After save the values should be unchanged
form.save()
featuresIterator = vl.getFeatures()
self.assertEqual(next(featuresIterator).attribute(0), 123)
self.assertEqual(next(featuresIterator).attribute(0), 456)

def test_on_update(self):
"""Test live update"""

Expand Down

0 comments on commit e3c5330

Please sign in to comment.