Skip to content
Permalink
Browse files

Adapting longlong test to general type inference test

  • Loading branch information
ccrook committed Mar 21, 2015
1 parent 532599e commit 0beb1707b68b9cf9f147223a381f10a89eb9d6a0
@@ -227,7 +227,7 @@ def recordDifference( record1, record2 ):
return "Field {0} differs: {1:.50} versus {2:.50}".format(k,repr(r1k),repr(r2k))
for k in record2.keys():
if k not in record1:
return "Output contains extra field {0} is missing".format(k)
return "Output contains extra field {0}".format(k)
return ''

def runTest( file, requests, **params ):
@@ -650,9 +650,9 @@ def test_037_csvt_file_invalid_file(self):
requests=None
runTest(filename,requests,**params)

def test_038_long_type(self):
def test_038_type_inference(self):
# Skip lines
filename='testlongs.csv'
filename='testtypes.csv'
params={'yField': 'lat', 'xField': 'lon', 'type': 'csv'}
requests=None
runTest(filename,requests,**params)
@@ -2035,36 +2035,46 @@ def test_033_reset_subset_string():
wanted['log']=[]
return wanted


def test_034_csvt_file():
wanted={}
wanted['uri']=u'file://testcsvt.csv?geomType=none&type=csv'
wanted['fieldTypes']=['integer', 'text', 'integer', 'double', 'text', 'text', 'text']
wanted['fieldTypes']=['integer', 'text', 'integer', 'double', 'text', 'text', 'text', 'text', 'text', 'text', 'longlong', 'longlong']
wanted['data']={
2L: {
'id': u'1',
'description': u'Test csvt 1',
'f1': u'1',
'f2': u'1.2',
'f3': u'01',
'f4': u'text',
'f5': u'times',
'fint': u'1',
'freal': u'1.2',
'fstr': u'1',
'fstr_1': u'text',
'fdatetime': u'2015-03-02T12:30:00',
'fdate': u'2014-12-30',
'ftime': u'23:55',
'flong': u'-456',
'flonglong': u'-678',
'field_12': u'NULL',
'#fid': 2L,
'#geometry': 'None',
},
},
3L: {
'id': u'2',
'description': u'Test csvt 2',
'f1': u'3',
'f2': u'1.5',
'f3': u'99',
'f4': u'23.5',
'f5': u'80',
'fint': u'3',
'freal': u'1.5',
'fstr': u'99',
'fstr_1': u'23.5',
'fdatetime': u'80',
'fdate': u'2015-03-28',
'ftime': u'2014-12-30',
'flong': u'01:55',
'flonglong': u'9189304972279762602',
'field_12': u'-3123724580211819352',
'#fid': 3L,
'#geometry': 'None',
},
}
wanted['log']=[]
},
}
wanted['log']=[
]
return wanted


@@ -2166,53 +2176,96 @@ def test_037_csvt_file_invalid_file():
wanted['log']=[]
return wanted

def test_038_long_type():
def test_038_type_inference():
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['uri']=u'file://testtypes.csv?yField=lat&xField=lon&type=csv'
wanted['fieldTypes']=['text', 'double', 'double', 'text', 'text', 'integer', 'longlong', 'double', 'text']
wanted['data']={
2L: {
'id': u'9189304972279762602',
'a_long': u'9189304972279762602',
'id': u'line1',
'description': u'1.0',
'lon': u'1.0',
'lat': u'1.0',
'an_integer': u'40',
'#geometry': 'POINT(1.0 1.0)',
'#fid':2L,
'description': 'line1'
},
'empty': u'NULL',
'text': u'NULL',
'int': u'0',
'longlong': u'0',
'real': u'NULL',
'text2': u'1',
'#fid': 2L,
'#geometry': 'POINT(1 1)',
},
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',
'id': u'line2',
'description': u'1.0',
'lon': u'1.0',
'lat': u'1.0',
'an_integer': u'7',
'#geometry': 'POINT(1.0 1.0)',
'#fid':4L,
'description': 'line3'
},
'lat': u'5.0',
'empty': u'NULL',
'text': u'1',
'int': u'NULL',
'longlong': u'9189304972279762602',
'real': u'1.3',
'text2': u'-4',
'#fid': 3L,
'#geometry': 'POINT(1 5)',
},
4L: {
'id': u'line3',
'description': u'5.0',
'lon': u'5.0',
'lat': u'5.0',
'empty': u'NULL',
'text': u'1xx',
'int': u'2',
'longlong': u'345',
'real': u'2.0',
'text2': u'1x',
'#fid': 4L,
'#geometry': 'POINT(5 5)',
},
5L: {
'id': u'-3',
'a_long': u'-3',
'lon': u'1.0',
'id': u'line4',
'description': u'5.0',
'lon': u'5.0',
'lat': u'1.0',
'an_integer': u'7',
'#geometry': 'POINT(1.0 1.0)',
'#fid':5L,
'description': 'line4'
}
}
wanted['log']=[]
'empty': u'NULL',
'text': u'A string',
'int': u'-3456',
'longlong': u'-3123724580211819352',
'real': u'-123.56',
'text2': u'NULL',
'#fid': 5L,
'#geometry': 'POINT(5 1)',
},
6L: {
'id': u'line5',
'description': u'3.0',
'lon': u'3.0',
'lat': u'1.0',
'empty': u'NULL',
'text': u'NULL',
'int': u'NULL',
'longlong': u'NULL',
'real': u'0.00023',
'text2': u'23',
'#fid': 6L,
'#geometry': 'POINT(3 1)',
},
7L: {
'id': u'line6',
'description': u'1.0',
'lon': u'1.0',
'lat': u'3.0',
'empty': u'NULL',
'text': u'1.5',
'int': u'9',
'longlong': u'42',
'real': u'99.0',
'text2': u'0',
'#fid': 7L,
'#geometry': 'POINT(1 3)',
},
}
wanted['log']=[
]
return wanted
@@ -1,4 +1,3 @@
id,description,f1,f2,f3,f4,f5
1,Test csvt 1,1,1.2,01,text,times
2,Test csvt 2,3,1.5,99,23.5,80

id,description,fint,freal,fstr,fstr,fdatetime,fdate,ftime,flong,flonglong
1,Test csvt 1,1,1.2,1,text,2015-03-02T12:30:00,2014-12-30,23:55,-456,-678
2,Test csvt 2,3,1.5,99,23.5,80,2015-03-28,2014-12-30,01:55,9189304972279762602,-3123724580211819352
@@ -1 +1 @@
integer,string,integer,real,string,string,datetime
integer,string,integer,real,string,string,datetime,date,time,long,longlong

This file was deleted.

@@ -0,0 +1,7 @@
id,lon,lat,empty,text,int,longlong,real,text2
line1,1.0,1.0,,,0,0,,1
line2,1.0,5.0,,1,,9189304972279762602,1.3,-4
line3,5.0,5.0,,1xx,2,345,2,1x
line4,5.0,1.0,,A string,-3456,-3123724580211819352,-123.56,,
line5,3.0,1.0,,,,,23e-5,23
line6,1.0,3.0,,1.5,9,42,99,0

0 comments on commit 0beb170

Please sign in to comment.
You can’t perform that action at this time.