Skip to content

Commit

Permalink
Added reasonType on cancellation
Browse files Browse the repository at this point in the history
  • Loading branch information
ktarasz committed Mar 16, 2016
1 parent d8a434d commit 7ce87ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 9 additions & 0 deletions openprocurement/tender/limited/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,16 @@ class Options:


class Cancellation(BaseCancellation):
class Options:
roles = {
'create': whitelist('reason', 'status', 'reasonType', 'cancellationOf', 'relatedLot'),
'edit': whitelist('status', 'reasonType'),
'embedded': schematics_embedded_role,
'view': schematics_default_role,
}

cancellationOf = StringType(required=True, choices=['tender'], default='tender')
reasonType = StringType(choices=['cancelled', 'unsuccessful'], default='cancelled')

def validate_relatedLot(self, data, relatedLot):
return
Expand Down
9 changes: 8 additions & 1 deletion openprocurement/tender/limited/tests/cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def test_create_tender_cancellation(self):
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
cancellation = response.json['data']
self.assertEqual(cancellation['reasonType'], 'cancelled')
self.assertEqual(cancellation['reason'], 'cancellation reason')
self.assertIn('id', cancellation)
self.assertIn(cancellation['id'], response.headers['Location'])
Expand All @@ -93,10 +94,11 @@ def test_create_tender_cancellation(self):
self.assertEqual(response.json['data']["status"], 'active')

response = self.app.post_json('/tenders/{}/cancellations?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'reason': 'first cancellation reason'}})
self.tender_id, self.tender_token), {'data': {'reason': 'first cancellation reason', 'reasonType': 'unsuccessful'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
first_cancellation = response.json['data']
self.assertEqual(first_cancellation['reasonType'], 'unsuccessful')
self.assertEqual(first_cancellation['reason'], 'first cancellation reason')

response = self.app.post_json('/tenders/{}/cancellations?acc_token={}'.format(
Expand Down Expand Up @@ -167,6 +169,11 @@ def test_patch_tender_cancellation(self):
self.assertEqual(response.content_type, 'application/json')
cancellation = response.json['data']

response = self.app.patch_json('/tenders/{}/cancellations/{}?acc_token={}'.format(self.tender_id, cancellation['id'], self.tender_token), {"data": {'reasonType': 'unsuccessful'}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data']["reasonType"], "unsuccessful")

response = self.app.patch_json('/tenders/{}/cancellations/{}?acc_token={}'.format(self.tender_id, cancellation['id'], self.tender_token), {"data": {"status": "active"}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
Expand Down

0 comments on commit 7ce87ad

Please sign in to comment.