Skip to content

Commit

Permalink
Merge pull request #61 from gorserg/fix_status_changes
Browse files Browse the repository at this point in the history
Контролювання переходів між статусами.
  • Loading branch information
kroman0 committed Aug 19, 2016
2 parents 61f36c9 + 9f651bf commit 814343a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
44 changes: 44 additions & 0 deletions openprocurement/tender/competitivedialogue/tests/stage1/bid.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,50 @@ def test_create_tender_bidder_invalid(self):
{u'description': [u'currency of bid should be identical to currency of value of tender'], u'location': u'body', u'name': u'value'},
])

def test_status_jumping(self):
""" Owner try set active.stage2.waiting status after pre-qualification """
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id),
{'data': {'selfEligible': True, 'selfQualified': True,
'tenderers': test_bids[0]['tenderers'], "value": {"amount": 500}}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
bid = response.json['data']
bid_token = response.json['access']['token']
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id),
{'data': {'selfEligible': True, 'selfQualified': True,
'tenderers': test_bids[1]['tenderers'], "value": {"amount": 499}}})

response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id),
{'data': {'selfEligible': True, 'selfQualified': True,
'tenderers': test_bids[1]['tenderers'], "value": {"amount": 499}}})

response = self.app.get('/tenders/{}/bids/{}'.format(self.tender_id, bid['id']), status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"],
"Can't view bid in current (active.tendering) tender status")

response = self.app.get('/tenders/{}/bids/{}?acc_token={}'.format(self.tender_id, bid['id'], bid_token))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data'], bid)

# switch to active.pre-qualification
self.set_status('active.pre-qualification', {"id": self.tender_id, 'status': 'active.tendering'})
self.app.authorization = ('Basic', ('chronograph', ''))
response = self.app.patch_json('/tenders/{}'.format(self.tender_id), {"data": {"id": self.tender_id}})
self.assertEqual(response.json['data']['status'], 'active.pre-qualification')

self.app.authorization = ('Basic', ('broker', ''))

response = self.app.patch_json('/tenders/{}?acc_token={}'.format(self.tender_id, self.tender_token),
{'data': {'status': 'active.stage2.waiting'}},
status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"],
"Can't update tender status")

def test_create_tender_bidder(self):
""" Test create dialog bdder """
# Create bid,
Expand Down
6 changes: 6 additions & 0 deletions openprocurement/tender/competitivedialogue/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ def patch_eu(self):
self.request.errors.add('body', 'data', 'Can\'t switch to \'active.pre-qualification.stand-still\' while not all bids are qualified')
self.request.errors.status = 403
return
elif self.request.authenticated_role == 'tender_owner' and \
self.request.validated['tender_status'] == 'active.pre-qualification' and \
tender.status != "active.pre-qualification.stand-still":
self.request.errors.add('body', 'data', 'Can\'t update tender status')
self.request.errors.status = 403
return

save_tender(self.request)
self.LOGGER.info('Updated tender {}'.format(tender.id),
Expand Down

0 comments on commit 814343a

Please sign in to comment.