Skip to content
Permalink
Browse files

Add unit tests

  • Loading branch information
pblottiere authored and m-kuhn committed Jul 7, 2017
1 parent 162063b commit e6de737fad1a9dca81aba7eb0a21ca7b0767ba61
Showing with 1,240 additions and 0 deletions.
  1. +33 −0 tests/src/python/test_qgsrelation.py
  2. +1,207 −0 tests/testdata/relations.qgs
@@ -19,9 +19,12 @@
QgsRelation,
QgsGeometry,
QgsPointXY,
QgsAttributeEditorElement,
QgsProject
)
from utilities import unitTestDataPath
from qgis.testing import start_app, unittest
import os

start_app()

@@ -156,6 +159,36 @@ def test_fieldPairs(self):

assert (rel.fieldPairs() == {'foreignkey': 'y'})

def testValidRelationAfterChangingStyle(self):
# load project
myPath = os.path.join(unitTestDataPath(), 'relations.qgs')
QgsProject.instance().read(myPath)

# get referenced layer
relations = QgsProject.instance().relationManager().relations()
relation = relations[list(relations.keys())[0]]
referencedLayer = relation.referencedLayer()

# check that the relation is valid
valid = False
for tab in referencedLayer.editFormConfig().tabs():
for t in tab.children():
if (t.type() == QgsAttributeEditorElement.AeTypeRelation):
valid = t.relation().isValid()
self.assertTrue(valid)

# update style
referencedLayer.styleManager().setCurrentStyle("custom")

# check that the relation is still valid
referencedLayer = relation.referencedLayer()
valid = False
for tab in referencedLayer.editFormConfig().tabs():
for t in tab.children():
if (t.type() == QgsAttributeEditorElement.AeTypeRelation):
valid = t.relation().isValid()
self.assertTrue(valid)


if __name__ == '__main__':
unittest.main()

0 comments on commit e6de737

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