Skip to content

Commit 6c3f418

Browse files
committedApr 1, 2013
Use ~.qgis2 and ~/.config/QuantumGIS/QGIS2.conf for settings for QGIS 2. Added unit test for memory provider.
1 parent 69ce13a commit 6c3f418

File tree

6 files changed

+122
-99
lines changed

6 files changed

+122
-99
lines changed
 

‎python/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def findPlugins(path):
140140

141141

142142
def updateAvailablePlugins():
143-
""" go thrgouh the plugin_paths list and find out what plugins are available """
143+
""" Go through the plugin_paths list and find out what plugins are available. """
144144
# merge the lists
145145
plugins = []
146146
metadata_parser = {}

‎src/app/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ int main( int argc, char *argv[] )
530530
// Set up the QSettings environment must be done after qapp is created
531531
QCoreApplication::setOrganizationName( "QuantumGIS" );
532532
QCoreApplication::setOrganizationDomain( "qgis.org" );
533-
QCoreApplication::setApplicationName( "QGIS" );
533+
QCoreApplication::setApplicationName( "QGIS2" );
534534
QCoreApplication::setAttribute( Qt::AA_DontShowIconsInMenus, false );
535535

536536
QSettings* customizationsettings;

‎src/app/qgisapp.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,8 @@ void QgisApp::readSettings()
865865
{
866866
QSettings settings;
867867
// get the users theme preference from the settings
868-
setTheme( settings.value( "/Themes", "default" ).toString() );
868+
// defaulting to 'gis' theme
869+
setTheme( settings.value( "/Themes", "gis" ).toString() );
869870

870871
// Add the recently accessed project file paths to the File menu
871872
mRecentProjectPaths = settings.value( "/UI/recentProjectsList" ).toStringList();

‎src/core/qgsapplication.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void QgsApplication::init( QString customConfigPath )
8484
{
8585
if ( customConfigPath.isEmpty() )
8686
{
87-
customConfigPath = QDir::homePath() + QString( "/.qgis/" );
87+
customConfigPath = QDir::homePath() + QString( "/.qgis2/" );
8888
}
8989

9090
qRegisterMetaType<QgsGeometry::Error>( "QgsGeometry::Error" );

‎tests/src/python/test_qgsmemoryprovider.py

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
)
3030
QGISAPP, CANVAS, IFACE, PARENT = getQgisTestApp()
3131

32+
3233
class TestQgsMemoryProvider(TestCase):
3334

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

5859
myMessage = ('Expected: %s\nGot: %s\n' %
59-
(3, len(provider.fields())))
60+
(3, len(provider.fields())))
6061

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

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

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

8384
myMessage = ('Expected: %s\nGot: %s\n' %
84-
(20, attrs[1].toInt()[0]))
85+
(20, attrs[1].toInt()[0]))
8586

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

8889
myMessage = ('Expected: %s\nGot: %s\n' %
89-
(0.3, attrs[2].toFloat()[0]))
90+
(0.3, attrs[2].toFloat()[0]))
9091

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

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

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

101+
def testGetFields(self):
102+
layer = QgsVectorLayer("Point", "test", "memory")
103+
provider = layer.dataProvider()
104+
105+
provider.addAttributes([QgsField("name", QVariant.String,),
106+
QgsField("age", QVariant.Int),
107+
QgsField("size", QVariant.Double)])
108+
myMessage = ('Expected: %s\nGot: %s\n' %
109+
(3, len(provider.fields())))
110+
111+
assert len(provider.fields()) == 3, myMessage
112+
113+
ft = QgsFeature()
114+
ft.setGeometry(QgsGeometry.fromPoint(QgsPoint(10,10)))
115+
ft.setAttributes([QVariant("Johny"),
116+
QVariant(20),
117+
QVariant(0.3)])
118+
provider.addFeatures([ft])
119+
120+
for f in provider.getFeatures(QgsFeatureRequest()):
121+
myMessage = ('Expected: %s\nGot: %s\n' %
122+
("Johny", str(f['name'].toString())))
123+
124+
self.assertEqual(str(f["name"].toString()), "Johny", myMessage)
125+
126+
100127
def testFromUri(self):
101128
"""Test we can construct the mem provider from a uri"""
102129
myMemoryLayer = QgsVectorLayer(

0 commit comments

Comments
 (0)
Please sign in to comment.