Skip to content
Permalink
Browse files
Use ~.qgis2 and ~/.config/QuantumGIS/QGIS2.conf for settings for QGIS…
… 2. Added unit test for memory provider.
  • Loading branch information
timlinux committed Apr 1, 2013
1 parent 69ce13a commit 6c3f418988fa9d60d36cf1a511db9b3ecf2f46b9
@@ -140,7 +140,7 @@ def findPlugins(path):


def updateAvailablePlugins():
""" go thrgouh the plugin_paths list and find out what plugins are available """
""" Go through the plugin_paths list and find out what plugins are available. """
# merge the lists
plugins = []
metadata_parser = {}
@@ -530,7 +530,7 @@ int main( int argc, char *argv[] )
// Set up the QSettings environment must be done after qapp is created
QCoreApplication::setOrganizationName( "QuantumGIS" );
QCoreApplication::setOrganizationDomain( "qgis.org" );
QCoreApplication::setApplicationName( "QGIS" );
QCoreApplication::setApplicationName( "QGIS2" );
QCoreApplication::setAttribute( Qt::AA_DontShowIconsInMenus, false );

QSettings* customizationsettings;
@@ -865,7 +865,8 @@ void QgisApp::readSettings()
{
QSettings settings;
// get the users theme preference from the settings
setTheme( settings.value( "/Themes", "default" ).toString() );
// defaulting to 'gis' theme
setTheme( settings.value( "/Themes", "gis" ).toString() );

// Add the recently accessed project file paths to the File menu
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();
@@ -84,7 +84,7 @@ void QgsApplication::init( QString customConfigPath )
{
if ( customConfigPath.isEmpty() )
{
customConfigPath = QDir::homePath() + QString( "/.qgis/" );
customConfigPath = QDir::homePath() + QString( "/.qgis2/" );
}

qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );
@@ -29,6 +29,7 @@
)
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()


class TestQgsMemoryProvider(TestCase):

def testPointCtor(self):
@@ -56,7 +57,7 @@ def testAddFeatures(self):
assert res, "Failed to add attributes"

myMessage = ('Expected: %s\nGot: %s\n' %
(3, len(provider.fields())))
(3, len(provider.fields())))

assert len(provider.fields()) == 3, myMessage

@@ -76,17 +77,17 @@ def testAddFeatures(self):
for f in provider.getFeatures(QgsFeatureRequest()):
attrs = f.attributes()
myMessage = ('Expected: %s\nGot: %s\n' %
("Johny", str(attrs[0].toString())))
("Johny", str(attrs[0].toString())))

assert str(attrs[0].toString()) == "Johny", myMessage

myMessage = ('Expected: %s\nGot: %s\n' %
(20, attrs[1].toInt()[0]))
(20, attrs[1].toInt()[0]))

assert attrs[1].toInt()[0] == 20, myMessage

myMessage = ('Expected: %s\nGot: %s\n' %
(0.3, attrs[2].toFloat()[0]))
(0.3, attrs[2].toFloat()[0]))

assert (attrs[0].toFloat()[0] - 0.3) < 0.0000001, myMessage

@@ -97,6 +98,32 @@ def testAddFeatures(self):

assert str(geom.exportToWkt()) == "POINT(10.0 10.0)", myMessage

def testGetFields(self):
layer = QgsVectorLayer("Point", "test", "memory")
provider = layer.dataProvider()

provider.addAttributes([QgsField("name", QVariant.String,),
QgsField("age", QVariant.Int),
QgsField("size", QVariant.Double)])
myMessage = ('Expected: %s\nGot: %s\n' %
(3, len(provider.fields())))

assert len(provider.fields()) == 3, myMessage

ft = QgsFeature()
ft.setGeometry(QgsGeometry.fromPoint(QgsPoint(10,10)))
ft.setAttributes([QVariant("Johny"),
QVariant(20),
QVariant(0.3)])
provider.addFeatures([ft])

for f in provider.getFeatures(QgsFeatureRequest()):
myMessage = ('Expected: %s\nGot: %s\n' %
("Johny", str(f['name'].toString())))

self.assertEqual(str(f["name"].toString()), "Johny", myMessage)


def testFromUri(self):
"""Test we can construct the mem provider from a uri"""
myMemoryLayer = QgsVectorLayer(

0 comments on commit 6c3f418

Please sign in to comment.