Skip to content

Commit

Permalink
update test listings
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaksymiv committed May 6, 2016
1 parent c0434a4 commit 4174ab3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion openprocurement/contracting/api/tests/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,26 @@ def test_listing(self):
self.assertEqual(len(response.json['data']), 0)

contracts = []
contracts_ids = []

for i in range(3):
offset = get_now().isoformat()
data = deepcopy(test_contract_data)
data['id'] = uuid4().hex
response = self.app.post_json('/contracts', {'data': data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
contracts_ids.append(response.json['data']['id'])

# 'draft' contracts is not visible
response = self.app.get('/contracts')
self.assertEqual(response.status, '200 OK')
self.assertEqual(len(response.json['data']), 0)

# reveal contracts
for contract_id in contracts_ids:
offset = get_now().isoformat()
response = self.app.patch_json('/contracts/{}'.format(contract_id), {'data': {'status': 'active'}})
self.assertEqual(response.status, '200 OK')
contracts.append(response.json['data'])

response = self.app.get('/contracts')
Expand Down Expand Up @@ -177,6 +189,9 @@ def test_listing(self):
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')

response = self.app.patch_json('/contracts/{}'.format(response.json['data']['id']), {'data': {'status': 'active'}})
self.assertEqual(response.status, '200 OK')

response = self.app.get('/contracts?mode=test')
self.assertEqual(response.status, '200 OK')
self.assertEqual(len(response.json['data']), 1)
Expand All @@ -194,6 +209,7 @@ def test_listing_changes(self):

for i in range(3):
data = deepcopy(test_contract_data)
data['status'] = 'active'
data['id'] = uuid4().hex
response = self.app.post_json('/contracts', {'data': data})
self.assertEqual(response.status, '201 Created')
Expand Down Expand Up @@ -256,6 +272,7 @@ def test_listing_changes(self):

test_contract_data2 = test_contract_data.copy()
test_contract_data2['mode'] = 'test'
test_contract_data2['status'] = 'active'
response = self.app.post_json('/contracts', {'data': test_contract_data2})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
Expand Down

0 comments on commit 4174ab3

Please sign in to comment.