Skip to content

Commit

Permalink
Fix bindings and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent 95fedd0 commit dbbf062
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion python/core/qgsmapthemecollection.sip
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,13 @@ class QgsMapThemeCollection : QObject
* @note added in QGIS 3.0
*/
void applyTheme( const QString& name, QgsLayerTreeGroup* root, QgsLayerTreeModel* model );

QgsProject* project();
void setProject( QgsProject* project );
signals:

/** Emitted when map themes within the collection are changed.
*/
void mapThemesChanged();
void projectChanged();
};

1 change: 1 addition & 0 deletions python/core/qgsprojectversion.sip
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class QgsProjectVersion
int minorVersion();
int subVersion();
QString text();
bool isNull() const;

/** Boolean equal operator
*/
Expand Down
2 changes: 1 addition & 1 deletion python/core/qgssnappingconfig.sip
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,6 @@ class QgsSnappingConfig
*/
bool removeLayers( const QList<QgsMapLayer*>& layers );
QgsProject* project() const;
void setProject(QgsProject* project);
void setProject( QgsProject* project );

};
2 changes: 1 addition & 1 deletion src/core/qgssnappingconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class CORE_EXPORT QgsSnappingConfig
QgsProject* project() const;

/**
* \copydoc project()
* The project from which the snapped layers should be retrieved
*
* \note Added in QGIS 3.0
*/
Expand Down
1 change: 0 additions & 1 deletion tests/src/python/test_qgsattributetablemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ def setUp(self):
self.cache = QgsVectorLayerCache(self.layer, 100)
self.am = QgsAttributeTableModel(self.cache)
self.am.loadLayer()
self.am.loadAttributes()

def tearDown(self):
del self.am
Expand Down
14 changes: 7 additions & 7 deletions tests/src/python/test_qgsfieldformatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import qgis # NOQA

from qgis.core import (QgsMapLayerRegistry, QgsFeature, QgsGeometry, QgsPoint,
from qgis.core import (QgsFeature, QgsGeometry, QgsPoint,
QgsProject, QgsRelation, QgsVectorLayer, NULL, QgsField,
QgsValueMapFieldFormatter, QgsValueRelationFieldFormatter,
QgsRelationReferenceFieldFormatter)
Expand All @@ -34,7 +34,7 @@ def test_representValue(self):
layer = QgsVectorLayer("none?field=number1:integer&field=number2:double&field=text1:string&field=number3:integer&field=number4:double&field=text2:string",
"layer", "memory")
self.assertTrue(layer.isValid())
QgsMapLayerRegistry.instance().addMapLayer(layer)
QgsProject.instance().addMapLayer(layer)
f = QgsFeature()
f.setAttributes([2, 2.5, 'NULL', None, None, None])
layer.dataProvider().addFeatures([f])
Expand All @@ -60,7 +60,7 @@ def test_representValue(self):
self.assertEqual(fieldFormatter.representValue(layer, 4, config, None, None), '(NULL)')
self.assertEqual(fieldFormatter.representValue(layer, 5, config, None, None), '(NULL)')

QgsMapLayerRegistry.instance().removeAllMapLayers()
QgsProject.instance().removeAllMapLayers()


class TestQgsValueRelationFieldFormatter(unittest.TestCase):
Expand All @@ -73,7 +73,7 @@ def test_representValue(self):
second_layer = QgsVectorLayer("none?field=pkid:integer&field=decoded:string",
"second_layer", "memory")
self.assertTrue(second_layer.isValid())
QgsMapLayerRegistry.instance().addMapLayer(second_layer)
QgsProject.instance().addMapLayer(second_layer)
f = QgsFeature()
f.setAttributes([123])
first_layer.dataProvider().addFeatures([f])
Expand Down Expand Up @@ -107,7 +107,7 @@ def test_representValue(self):
config = {'Layer': second_layer.id(), 'Key': 'pkid', 'Value': 'invalid'}
self.assertEqual(fieldFormatter.representValue(first_layer, 0, config, None, '456'), '(456)')

QgsMapLayerRegistry.instance().removeMapLayer(second_layer.id())
QgsProject.instance().removeMapLayer(second_layer.id())


class TestQgsRelationReferenceFieldFormatter(unittest.TestCase):
Expand All @@ -120,7 +120,7 @@ def test_representValue(self):
second_layer = QgsVectorLayer("none?field=pkid:integer&field=decoded:string",
"second_layer", "memory")
self.assertTrue(second_layer.isValid())
QgsMapLayerRegistry.instance().addMapLayers([first_layer, second_layer])
QgsProject.instance().addMapLayers([first_layer, second_layer])
f = QgsFeature()
f.setAttributes([123])
first_layer.dataProvider().addFeatures([f])
Expand Down Expand Up @@ -196,7 +196,7 @@ def test_representValue(self):
second_layer.setDisplayExpression('decoded')
self.assertEqual(fieldFormatter.representValue(first_layer, 0, config, None, '123'), '123')

QgsMapLayerRegistry.instance().removeAllMapLayers()
QgsProject.instance().removeAllMapLayers()

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion tests/testdata/provider/testdata_pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ CREATE TABLE qgis_test.widget_styles(
);

INSERT INTO qgis_editor_widget_styles VALUES
('qgis_test', 'widget_styles', 'fld1', 'FooEdit', '<config type="Map"><Option name="param1" value="value1" type="String"/><Option name="param2" value="2" type="String"/></config>');
('qgis_test', 'widget_styles', 'fld1', 'FooEdit', '<config type="Map"><Option name="param1" value="value1" type="QString"/><Option name="param2" value="2" type="QString"/></config>');


-----------------------------
Expand Down

0 comments on commit dbbf062

Please sign in to comment.