Skip to content

Commit

Permalink
Merge branch 'master' into one_button_ESC_key_handling
Browse files Browse the repository at this point in the history
  • Loading branch information
gacarrillor committed Jul 20, 2017
2 parents a231f16 + 6e49403 commit 5ba0cb7
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ matrix:
env:
- LLVM_VERSION=3.8
- TRAVIS_CONFIG=linux
dist: precise
sudo: false
cache:
apt: true
Expand Down
11 changes: 8 additions & 3 deletions python/plugins/db_manager/db_plugins/postgis/plugin_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,16 @@ def test_unicodeInQuery(self):
obj = QObject() # needs to be kept alive
database = PGDatabase(obj, QgsDataSourceUri())
self.assertIsInstance(database, PGDatabase)
sql = "SELECT 'é'::text"
res = database.sqlResultModel(sql, obj)
# SQL as string literal
res = database.sqlResultModel("SELECT 'é'::text", obj)
self.assertIsInstance(res, PGSqlResultModel)
dat = res.getData(0, 0)
self.assertEqual(dat, "é")
self.assertEqual(dat, u"é")
# SQL as unicode literal
res = database.sqlResultModel(u"SELECT 'é'::text", obj)
self.assertIsInstance(res, PGSqlResultModel)
dat = res.getData(0, 0)
self.assertEqual(dat, u"é")


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsfieldcombobox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void QgsFieldComboBox::setField( const QString &fieldName )
QModelIndex proxyIdx = mFieldProxyModel->mapFromSource( idx );
if ( proxyIdx.isValid() )
{
setCurrentIndex( idx.row() );
setCurrentIndex( proxyIdx.row() );
emit fieldChanged( currentField() );
return;
}
Expand Down
1 change: 1 addition & 0 deletions tests/src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ADD_PYTHON_TEST(PyQgsExtentGroupBox test_qgsextentgroupbox.py)
ADD_PYTHON_TEST(PyQgsFeature test_qgsfeature.py)
ADD_PYTHON_TEST(PyQgsFeatureSink test_qgsfeaturesink.py)
ADD_PYTHON_TEST(PyQgsFeatureSource test_qgsfeaturesource.py)
ADD_PYTHON_TEST(PyQgsFieldComboBoxTest test_qgsfieldcombobox.py)
ADD_PYTHON_TEST(PyQgsFieldFormattersTest test_qgsfieldformatters.py)
ADD_PYTHON_TEST(PyQgsFillSymbolLayers test_qgsfillsymbollayers.py)
ADD_PYTHON_TEST(PyQgsProject test_qgsproject.py)
Expand Down
4 changes: 2 additions & 2 deletions tests/src/python/test_provider_wfs_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def test(self):
# Add layer
self.addWfsLayer_uri = None
self.addWfsLayer_layer_name = None
main_dialog.addWfsLayer.connect(self.slotAddWfsLayer)
main_dialog.addVectorLayer.connect(self.slotAddWfsLayer)
QTest.mouseClick(buttonAdd, Qt.LeftButton)
self.assertEqual(self.addWfsLayer_uri, ' restrictToRequestBBOX=\'1\' srsname=\'EPSG:4326\' typename=\'my:typename\' url=\'' + "http://" + expected_endpoint + '\' version=\'auto\' table="" sql=')
self.assertEqual(self.addWfsLayer_layer_name, 'my:typename')
Expand Down Expand Up @@ -290,7 +290,7 @@ def test(self):

self.addWfsLayer_uri = None
self.addWfsLayer_layer_name = None
main_dialog.addWfsLayer.connect(self.slotAddWfsLayer)
main_dialog.addVectorLayer.connect(self.slotAddWfsLayer)
QTest.mouseClick(buttonAdd, Qt.LeftButton)
self.assertEqual(self.addWfsLayer_uri, ' restrictToRequestBBOX=\'1\' srsname=\'EPSG:4326\' typename=\'my:typename\' url=\'' + "http://" + expected_endpoint + '\' version=\'auto\' table="" sql=SELECT * FROM typename WHERE 1 = 1')
self.assertEqual(self.addWfsLayer_layer_name, 'my:typename')
Expand Down
65 changes: 65 additions & 0 deletions tests/src/python/test_qgsfieldcombobox.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-
"""QGIS Unit tests for QgsFieldComboBox
.. note:: This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
"""
__author__ = 'Nyall Dawson'
__date__ = '20/07/2017'
__copyright__ = 'Copyright 2017, The QGIS Project'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

import qgis # NOQA

from qgis.core import QgsFields, QgsVectorLayer, QgsFieldProxyModel
from qgis.gui import QgsFieldComboBox
from qgis.PyQt.QtCore import QVariant, Qt

from qgis.testing import start_app, unittest

start_app()


def create_layer():
layer = QgsVectorLayer("Point?field=fldtxt:string&field=fldint:integer&field=fldint2:integer",
"addfeat", "memory")
assert layer.isValid()
return layer


def create_model():
l = create_layer()
m = QgsFieldModel()
m.setLayer(l)
return l, m


class TestQgsFieldComboBox(unittest.TestCase):

def testGettersSetters(self):
""" test combobox getters/setters """
l = create_layer()
w = QgsFieldComboBox()
w.setLayer(l)
self.assertEqual(w.layer(), l)

w.setField('fldint')
self.assertEqual(w.currentField(), 'fldint')

def testFilter(self):
""" test setting field with filter """
l = create_layer()
w = QgsFieldComboBox()
w.setLayer(l)
w.setFilters(QgsFieldProxyModel.Int)
self.assertEqual(w.layer(), l)

w.setField('fldint')
self.assertEqual(w.currentField(), 'fldint')


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

0 comments on commit 5ba0cb7

Please sign in to comment.