Skip to content

Commit

Permalink
Use ~.qgis2 and ~/.config/QuantumGIS/QGIS2.conf for settings for QGIS…
Browse files Browse the repository at this point in the history
… 2. Added unit test for memory provider.
  • Loading branch information
timlinux committed Apr 1, 2013
1 parent 69ce13a commit 6c3f418
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 99 deletions.
2 changes: 1 addition & 1 deletion python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down
2 changes: 1 addition & 1 deletion src/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
35 changes: 31 additions & 4 deletions tests/src/python/test_qgsmemoryprovider.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
)
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()


class TestQgsMemoryProvider(TestCase):

def testPointCtor(self):
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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(
Expand Down
Loading

0 comments on commit 6c3f418

Please sign in to comment.