@@ -46,35 +46,38 @@ test('GET /api/v1/sql', function(){
46
46
} ) ;
47
47
48
48
49
- test ( 'GET /api/v1/sql with SQL parameter on SELECT only. No oAuth included ' , function ( ) {
49
+ test ( 'GET /api/v1/sql with SQL parameter on SELECT only. No oAuth included ' , function ( done ) {
50
50
assert . response ( app , {
51
51
url : '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&database=cartodb_test_user_1_db' ,
52
52
method : 'GET'
53
- } , {
54
- status : 200
53
+ } , { } , function ( res ) {
54
+ assert . equal ( res . statusCode , 200 , res . body ) ;
55
+ done ( ) ;
55
56
} ) ;
56
57
} ) ;
57
58
58
59
59
- test ( 'GET /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers' , function ( ) {
60
+ test ( 'GET /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers' , function ( done ) {
60
61
assert . response ( app , {
61
62
url : '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4' ,
62
63
headers : { host : 'vizzuality.cartodb.com' } ,
63
64
method : 'GET'
64
- } , {
65
- status : 200
65
+ } , { } , function ( res ) {
66
+ assert . equal ( res . statusCode , 200 , res . body ) ;
67
+ done ( ) ;
66
68
} ) ;
67
69
} ) ;
68
70
69
71
70
- test ( 'POST /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers' , function ( ) {
72
+ test ( 'POST /api/v1/sql with SQL parameter on SELECT only. no database param, just id using headers' , function ( done ) {
71
73
assert . response ( app , {
72
74
url : '/api/v1/sql' ,
73
75
data : querystring . stringify ( { q : "SELECT * FROM untitle_table_4" } ) ,
74
76
headers : { host : 'vizzuality.cartodb.com' , 'Content-Type' : 'application/x-www-form-urlencoded' } ,
75
77
method : 'POST'
76
- } , {
77
- status : 200
78
+ } , { } , function ( res ) {
79
+ assert . equal ( res . statusCode , 200 , res . body ) ;
80
+ done ( ) ;
78
81
} ) ;
79
82
} ) ;
80
83
@@ -121,9 +124,8 @@ test('GET /api/v1/sql with SQL parameter and geojson format, ensuring content-di
121
124
url : '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson' ,
122
125
headers : { host : 'vizzuality.cartodb.com' } ,
123
126
method : 'GET'
124
- } , {
125
- status : 200
126
- } , function ( res ) {
127
+ } , { } , function ( res ) {
128
+ assert . equal ( res . statusCode , 200 , res . body ) ;
127
129
var cd = res . header ( 'Content-Disposition' ) ;
128
130
assert . equal ( true , / f i l e n a m e = c a r t o d b - q u e r y .g e o j s o n / gi. test ( cd ) ) ;
129
131
done ( ) ;
@@ -135,9 +137,8 @@ test('GET /api/v1/sql with SQL parameter and no format, ensuring content-disposi
135
137
url : '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4' ,
136
138
headers : { host : 'vizzuality.cartodb.com' } ,
137
139
method : 'GET'
138
- } , {
139
- status : 200
140
- } , function ( res ) {
140
+ } , { } , function ( res ) {
141
+ assert . equal ( res . statusCode , 200 , res . body ) ;
141
142
var cd = res . header ( 'Content-Disposition' ) ;
142
143
assert . equal ( true , / f i l e n a m e = c a r t o d b - q u e r y .j s o n / gi. test ( cd ) ) ;
143
144
done ( ) ;
@@ -163,9 +164,8 @@ test('GET /api/v1/sql as geojson limiting decimal places', function(done){
163
164
url : '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson&dp=1' ,
164
165
headers : { host : 'vizzuality.cartodb.com' } ,
165
166
method : 'GET'
166
- } , {
167
- status : 200
168
- } , function ( res ) {
167
+ } , { } , function ( res ) {
168
+ assert . equal ( res . statusCode , 200 , res . body ) ;
169
169
var result = JSON . parse ( res . body ) ;
170
170
assert . equal ( 1 , checkDecimals ( result . features [ 0 ] . geometry . coordinates [ 0 ] , '.' ) ) ;
171
171
done ( ) ;
@@ -177,9 +177,8 @@ test('GET /api/v1/sql as geojson with default dp as 6', function(done){
177
177
url : '/api/v1/sql?q=SELECT%20*%20FROM%20untitle_table_4&format=geojson' ,
178
178
headers : { host : 'vizzuality.cartodb.com' } ,
179
179
method : 'GET'
180
- } , {
181
- status : 200
182
- } , function ( res ) {
180
+ } , { } , function ( res ) {
181
+ assert . equal ( res . statusCode , 200 , res . body ) ;
183
182
var result = JSON . parse ( res . body ) ;
184
183
assert . equal ( 6 , checkDecimals ( result . features [ 0 ] . geometry . coordinates [ 0 ] , '.' ) ) ;
185
184
done ( ) ;
@@ -191,9 +190,8 @@ test('GET /api/v1/sql as csv', function(done){
191
190
url : '/api/v1/sql?q=SELECT%20cartodb_id,ST_AsEWKT(the_geom)%20as%20geom%20FROM%20untitle_table_4%20LIMIT%201&format=csv' ,
192
191
headers : { host : 'vizzuality.cartodb.com' } ,
193
192
method : 'GET'
194
- } , {
195
- status : 200
196
- } , function ( res ) {
193
+ } , { } , function ( res ) {
194
+ assert . equal ( res . statusCode , 200 , res . body ) ;
197
195
var body = "cartodb_id,geom\r\n1,SRID=4326;POINT(-3.699732 40.423012)" ;
198
196
assert . equal ( body , res . body ) ;
199
197
done ( ) ;
@@ -205,9 +203,8 @@ test('GET /api/v1/sql as csv, properly escaped', function(done){
205
203
url : '/api/v1/sql?q=SELECT%20cartodb_id,%20address%20FROM%20untitle_table_4%20LIMIT%201&format=csv' ,
206
204
headers : { host : 'vizzuality.cartodb.com' } ,
207
205
method : 'GET'
208
- } , {
209
- status : 200
210
- } , function ( res ) {
206
+ } , { } , function ( res ) {
207
+ assert . equal ( res . statusCode , 200 , res . body ) ;
211
208
var body = 'cartodb_id,address\r\n1,"Calle de Pérez Galdós 9, Madrid, Spain"' ;
212
209
assert . equal ( body , res . body ) ;
213
210
done ( ) ;
0 commit comments