Skip to content

Commit

Permalink
Merge pull request #15 from VolVoz/master
Browse files Browse the repository at this point in the history
cancellation-s
  • Loading branch information
vmaksymiv committed Feb 17, 2016
2 parents bb27ae8 + 9ead148 commit 683def7
Showing 1 changed file with 53 additions and 6 deletions.
59 changes: 53 additions & 6 deletions openprocurement/tender/limited/tests/cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,31 @@ 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': 'cancellation reason', 'status': 'active'}})
self.tender_id, self.tender_token), {'data': {'reason': 'first cancellation reason'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
cancellation = response.json['data']
self.assertEqual(cancellation['reason'], 'cancellation reason')
self.assertEqual(cancellation['status'], 'active')
self.assertIn('id', cancellation)
self.assertIn(cancellation['id'], response.headers['Location'])
first_cancellation = response.json['data']
self.assertEqual(first_cancellation['reason'], 'first cancellation reason')

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

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

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

response = self.app.get('/tenders/{}'.format(self.tender_id))
self.assertEqual(response.status, '200 OK')
Expand All @@ -111,6 +128,36 @@ def test_create_tender_cancellation(self):
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], "Can't add cancellation in current (cancelled) tender status")

def test_create_tender_cancellation_with_post(self):
response = self.app.post_json('/tenders/{}/cancellations?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'reason': 'cancellation reason'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
cancellation = response.json['data']
self.assertEqual(cancellation['reason'], 'cancellation reason')
self.assertIn('id', cancellation)
self.assertIn(cancellation['id'], response.headers['Location'])

response = self.app.get('/tenders/{}'.format(self.tender_id))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
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': 'cancellation reason', 'status': 'active'}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
cancellation = response.json['data']
self.assertEqual(cancellation['reason'], 'cancellation reason')
self.assertEqual(cancellation['status'], 'active')
self.assertIn('id', cancellation)
self.assertIn(cancellation['id'], response.headers['Location'])

response = self.app.get('/tenders/{}'.format(self.tender_id))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data']["status"], 'cancelled')

def test_patch_tender_cancellation(self):
response = self.app.post_json('/tenders/{}/cancellations?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'reason': 'cancellation reason'}})
Expand Down

0 comments on commit 683def7

Please sign in to comment.