@@ -223,17 +223,17 @@ def test_create_tender(self):
223223 response = self .app .post_json ('/tenders?opt_jsonp=callback' , {"data" : test_tender_data })
224224 self .assertEqual (response .status , '201 Created' )
225225 self .assertEqual (response .content_type , 'application/javascript' )
226- self .assertTrue ('callback({"data": {" ' in response .body )
226+ self .assertTrue ('callback({"' in response .body )
227227
228228 response = self .app .post_json ('/tenders?opt_pretty=1' , {"data" : test_tender_data })
229229 self .assertEqual (response .status , '201 Created' )
230230 self .assertEqual (response .content_type , 'application/json' )
231- self .assertTrue ('{\n "data": { \n " ' in response .body )
231+ self .assertTrue ('{\n "' in response .body )
232232
233233 response = self .app .post_json ('/tenders' , {"data" : test_tender_data , "options" : {"pretty" : True }})
234234 self .assertEqual (response .status , '201 Created' )
235235 self .assertEqual (response .content_type , 'application/json' )
236- self .assertTrue ('{\n "data": { \n " ' in response .body )
236+ self .assertTrue ('{\n "' in response .body )
237237
238238 def test_get_tender (self ):
239239 response = self .app .get ('/tenders' )
@@ -279,6 +279,16 @@ def test_put_tender(self):
279279 self .assertEqual (tender , new_tender )
280280 self .assertNotEqual (dateModified , new_dateModified )
281281
282+ response = self .app .patch_json ('/tenders/{}' .format (tender ['id' ]), {'data' : {'status' : 'complete' }})
283+ self .assertEqual (response .status , '200 OK' )
284+ self .assertEqual (response .content_type , 'application/json' )
285+
286+ response = self .app .put_json ('/tenders/{}' .format (
287+ tender ['id' ]), {'data' : tender }, status = 403 )
288+ self .assertEqual (response .status , '403 Forbidden' )
289+ self .assertEqual (response .content_type , 'application/json' )
290+ self .assertEqual (response .json ['errors' ][0 ]["description" ], "Can't change tender in current status" )
291+
282292 def test_patch_tender (self ):
283293 response = self .app .get ('/tenders' )
284294 self .assertEqual (response .status , '200 OK' )
@@ -312,6 +322,17 @@ def test_patch_tender(self):
312322 self .assertEqual (revisions [0 ][u'changes' ][0 ]['op' ], u'remove' )
313323 self .assertEqual (revisions [0 ][u'changes' ][0 ]['path' ], u'/procurementMethod' )
314324
325+ response = self .app .patch_json ('/tenders/{}' .format (
326+ tender ['id' ]), {'data' : {'items' : [test_tender_data ['items' ][0 ]]}})
327+ self .assertEqual (response .status , '200 OK' )
328+ self .assertEqual (response .content_type , 'application/json' )
329+
330+ response = self .app .patch_json ('/tenders/{}' .format (
331+ tender ['id' ]), {'data' : {'items' : [{}, test_tender_data ['items' ][0 ]]}})
332+ self .assertEqual (response .status , '200 OK' )
333+ self .assertEqual (response .content_type , 'application/json' )
334+ self .assertEqual (response .json ['data' ]['items' ][0 ], response .json ['data' ]['items' ][1 ])
335+
315336 response = self .app .patch_json ('/tenders/{}' .format (
316337 tender ['id' ]), {'data' : {'enquiryPeriod' : {'endDate' : new_dateModified2 }}})
317338 self .assertEqual (response .status , '200 OK' )
@@ -328,6 +349,15 @@ def test_patch_tender(self):
328349 self .assertEqual (response .content_type , 'application/json' )
329350 self .assertTrue ('auctionUrl' in response .json ['data' ])
330351
352+ response = self .app .patch_json ('/tenders/{}' .format (tender ['id' ]), {'data' : {'status' : 'complete' }})
353+ self .assertEqual (response .status , '200 OK' )
354+ self .assertEqual (response .content_type , 'application/json' )
355+
356+ response = self .app .patch_json ('/tenders/{}' .format (tender ['id' ]), {'data' : {'status' : 'active.auction' }}, status = 403 )
357+ self .assertEqual (response .status , '403 Forbidden' )
358+ self .assertEqual (response .content_type , 'application/json' )
359+ self .assertEqual (response .json ['errors' ][0 ]["description" ], "Can't change tender in current status" )
360+
331361 def test_dateModified_tender (self ):
332362 response = self .app .get ('/tenders' )
333363 self .assertEqual (response .status , '200 OK' )
0 commit comments