Skip to content
Permalink
Browse files

Fix bindings and tests

  • Loading branch information
m-kuhn committed Dec 20, 2016
1 parent 95fedd0 commit dbbf062e5d1ac092fc533f23ecf67be60ea55970
@@ -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();
};

@@ -20,6 +20,7 @@ class QgsProjectVersion
int minorVersion();
int subVersion();
QString text();
bool isNull() const;

/** Boolean equal operator
*/
@@ -222,6 +222,6 @@ class QgsSnappingConfig
*/
bool removeLayers( const QList<QgsMapLayer*>& layers );
QgsProject* project() const;
void setProject(QgsProject* project);
void setProject( QgsProject* project );

};
@@ -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
*/
@@ -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
@@ -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)
@@ -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])
@@ -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):
@@ -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])
@@ -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):
@@ -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])
@@ -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()
@@ -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>');


-----------------------------

0 comments on commit dbbf062

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