Skip to content

Commit

Permalink
Added testcase for longs
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinux committed Mar 19, 2015
1 parent d996966 commit 48591df
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
8 changes: 7 additions & 1 deletion tests/src/python/test_qgsdelimitedtextprovider.py
Expand Up @@ -12,7 +12,7 @@
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'

# This module provides unit test for the delimtied text provider. It uses data files in
# This module provides unit test for the delimited text provider. It uses data files in
# the testdata/delimitedtext directory.
#
# New tests can be created (or existing ones updated), but incorporating a createTest
Expand Down Expand Up @@ -650,6 +650,12 @@ def test_037_csvt_file_invalid_file(self):
requests=None
runTest(filename,requests,**params)

def test_038_long_type(self):
# Skip lines
filename='testlongs.csv'
params={'yField': 'lat', 'xField': 'lon', 'type': 'csv'}
requests=None
runTest(filename,requests,**params)

if __name__ == '__main__':
unittest.main()
51 changes: 51 additions & 0 deletions tests/src/python/test_qgsdelimitedtextprovider_wanted.py
Expand Up @@ -2165,3 +2165,54 @@ def test_037_csvt_file_invalid_file():
}
wanted['log']=[]
return wanted

def test_038_long_type():
wanted={}
filename="testlongs.csv"
wanted['uri']=u'file://{}?yField={}&xField={}&type={}'.format(filename,"lat","lon","csv")
wanted['fieldTypes']=['longlong', 'text', 'double', 'double', 'integer']
# long is casted as longlong because of QVariant limitation
wanted['data']={
2L: {
'id': u'9189304972279762602',
'a_long': u'9189304972279762602',
'lon': u'1.0',
'lat': u'1.0',
'an_integer': u'40',
'#geometry': 'POINT(1.0 1.0)',
'#fid':2L,
'description': 'line1'
},
3L: {
'id': u'9189304972279762602',
'a_long': u'9189304972279762602',
'lon': u'2.2',
'lat': u'2.5',
'an_integer': u'5',
'#geometry': 'POINT(2.2 2.5)',
'#fid':3L,
'description': 'line2'
},
4L: {
'id': u'-3123724580211819352',
'a_long': u'-3123724580211819352',
'lon': u'1.0',
'lat': u'1.0',
'an_integer': u'7',
'#geometry': 'POINT(1.0 1.0)',
'#fid':4L,
'description': 'line3'
},
5L: {
'id': u'-3',
'a_long': u'-3',
'lon': u'1.0',
'lat': u'1.0',
'an_integer': u'7',
'#geometry': 'POINT(1.0 1.0)',
'#fid':5L,
'description': 'line4'
}
}
wanted['log']=[]
return wanted
5 changes: 5 additions & 0 deletions tests/testdata/delimitedtext/testlongs.csv
@@ -0,0 +1,5 @@
a_long,description,lon,lat,an_integer
9189304972279762602,line1,1.0,1.0,40
9189304972279762602,line2,2.2,2.5,5
-3123724580211819352,line3,1.0,1.0,7
-3,line4,1.0,1.0,7

0 comments on commit 48591df

Please sign in to comment.