Skip to content

Commit

Permalink
test credential generation for each possible contract status
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaksymiv committed May 5, 2016
1 parent 9da02df commit 008bfde
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions openprocurement/contracting/api/tests/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,32 @@ def test_generate_credentials(self):
token2 = response.json['access']['token']
self.assertNotEqual(token1, token2)

# first access token is non-workable
response = self.app.patch_json('/contracts/{}?acc_token={}'.format(self.contract_id, token1),
{"data": {"status": "active"}}, status=403)
self.assertEqual(response.status, '403 Forbidden')

# activate contract and try to generate credentials
response = self.app.patch_json('/contracts/{}?acc_token={}'.format(self.contract_id, token2),
{"data": {"status": "active"}})
self.assertEqual(response.status, '200 OK')

response = self.app.patch_json('/contracts/{0}/credentials?acc_token={1}'.format(self.contract_id, tender_token),
{'data': ''}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.json['errors'], [
{u'description': u"Can't generate credentials in current (active) contract status", u'location': u'body', u'name': u'data'}])

# terminated contract is also protected
response = self.app.patch_json('/contracts/{}?acc_token={}'.format(self.contract_id, token2),
{"data": {"status": "terminated"}})
self.assertEqual(response.status, '200 OK')

response = self.app.patch_json('/contracts/{0}/credentials?acc_token={1}'.format(self.contract_id, tender_token),
{'data': ''}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.json['errors'], [
{u'description': u"Can't generate credentials in current (terminated) contract status", u'location': u'body', u'name': u'data'}])

def suite():
suite = unittest.TestSuite()
Expand Down

0 comments on commit 008bfde

Please sign in to comment.