Skip to content
Permalink
Browse files

Fix python bindings for QgsRelation.fieldPairs()

  • Loading branch information
m-kuhn committed Aug 18, 2014
1 parent 978642a commit 1b205be604d2909bfac532ba5de382f59f2482b6
Showing with 20 additions and 1 deletion.
  1. +2 −1 python/core/qgsrelation.sip
  2. +18 −0 tests/src/python/test_qgsrelation.py
@@ -165,7 +165,8 @@ class QgsRelation
*/
QMap< QString, QString > fieldPairs() const;
%MethodCode
QList< QgsRelation::FieldPair > pairs = sipCpp->fieldPairs();
const QList< QgsRelation::FieldPair >& pairs = sipCpp->fieldPairs();
sipRes = new QMap< QString, QString >();
Q_FOREACH( const QgsRelation::FieldPair& pair, pairs )
{
sipRes->insert( pair.first, pair.second );
@@ -119,5 +119,23 @@ def test_getRelatedFeatures(self):

QgsMapLayerRegistry.instance().removeAllMapLayers()

def test_fieldPairs(self):
referencedLayer = createReferencedLayer()
referencingLayer = createReferencingLayer()
QgsMapLayerRegistry.instance().addMapLayers([referencedLayer,referencingLayer])

rel = QgsRelation()

rel.setRelationId( 'rel1' )
rel.setRelationName( 'Relation Number One' )
rel.setReferencingLayer( referencingLayer.id() )
rel.setReferencedLayer( referencedLayer.id() )
rel.addFieldPair( 'foreignkey', 'y' )

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

QgsMapLayerRegistry.instance().removeAllMapLayers()


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

0 comments on commit 1b205be

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