@@ -1244,6 +1244,50 @@ def testDispatch(self):
12441244 status = json_dict ['data' ]['status' ]
12451245 self .assertEqual (status , 'ok' )
12461246
1247+ # TEST #9
1248+ # GET: test that version can be set with
1249+ # ; version=z or application/vnd.x.y-vz+json
1250+ # simulate: /rest/data/issue
1251+ headers = {"accept" : "application/json; version=z" }
1252+ self .headers = headers
1253+ self .server .client .request .headers .get = self .get_header
1254+ results = self .server .dispatch ('GET' ,
1255+ "/rest/data/issue/1" , self .empty_form )
1256+ print (results )
1257+ json_dict = json .loads (b2s (results ))
1258+ self .assertEqual (json_dict ['error' ]['status' ], 400 )
1259+ self .assertEqual (json_dict ['error' ]['msg' ],
1260+ "Unrecognized version: z. See /rest without "
1261+ "specifying version for supported versions." )
1262+
1263+ headers = {"accept" : "application/vnd.roundup.test-vz+json" }
1264+ self .headers = headers
1265+ self .server .client .request .headers .get = self .get_header
1266+ results = self .server .dispatch ('GET' ,
1267+ "/rest/data/issue/1" , self .empty_form )
1268+ print (results )
1269+ self .assertEqual (self .server .client .response_code , 400 )
1270+ json_dict = json .loads (b2s (results ))
1271+ self .assertEqual (json_dict ['error' ]['status' ], 400 )
1272+ self .assertEqual (json_dict ['error' ]['msg' ],
1273+ "Unrecognized version: z. See /rest without "
1274+ "specifying version for supported versions." )
1275+
1276+ # verify that version priority is correct; should be version=...
1277+ headers = {"accept" : "application/vnd.roundup.test-vz+json; version=a"
1278+ }
1279+ self .headers = headers
1280+ self .server .client .request .headers .get = self .get_header
1281+ results = self .server .dispatch ('GET' ,
1282+ "/rest/data/issue/1" , self .empty_form )
1283+ print (results )
1284+ self .assertEqual (self .server .client .response_code , 400 )
1285+ json_dict = json .loads (b2s (results ))
1286+ self .assertEqual (json_dict ['error' ]['status' ], 400 )
1287+ self .assertEqual (json_dict ['error' ]['msg' ],
1288+ "Unrecognized version: a. See /rest without "
1289+ "specifying version for supported versions." )
1290+
12471291 del (self .headers )
12481292
12491293 def testPostPOE (self ):
0 commit comments