Skip to content

Commit

Permalink
Add tests for checking tender.yearlyPaymentsPercentageRange values
Browse files Browse the repository at this point in the history
  • Loading branch information
annawzz committed Sep 16, 2017
1 parent a5a51a0 commit bacd077
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions openprocurement/tender/esco/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
tender_value,
tender_min_value,
tender_minimal_step_invalid,
tender_yearlyPaymentsPercentageRange_invalid,
#TestTenderEU
create_tender_invalid,
patch_tender,
Expand All @@ -51,6 +52,7 @@ class TenderESCOTest(BaseESCOWebTest):
test_tender_value = snitch(tender_value)
test_tender_min_value = snitch(tender_min_value)
test_tender_minimal_step_invalid = snitch(tender_minimal_step_invalid)
test_tender_yearlyPaymentsPercentageRange_invalid = snitch(tender_yearlyPaymentsPercentageRange_invalid)


class TestTenderEU(BaseESCOContentWebTest, TenderResourceTestMixin, TenderUAResourceTestMixin):
Expand Down
28 changes: 28 additions & 0 deletions openprocurement/tender/esco/tests/tender_blanks.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,34 @@ def tender_minimal_step_invalid(self):
self.assertNotIn('minimalStep', response.json['data'])


def tender_yearlyPaymentsPercentageRange_invalid(self):
data = deepcopy(self.initial_data)
data['yearlyPaymentsPercentageRange'] = 0.6
response = self.app.post_json('/tenders', {'data': data}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': [u'when fundingKind is other, yearlyPaymentsPercentageRange should be equal 0.8'], u'location': u'body', u'name': u'yearlyPaymentsPercentageRange'}
])

data['fundingKind'] = 'budget'
response = self.app.post_json('/tenders', {'data': data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data']['fundingKind'], 'budget')
tender_id = response.json['data']['id']
tender_token = response.json['access']['token']

response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, tender_token), {'data': {'yearlyPaymentsPercentageRange': 1}}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': [u'when fundingKind is budget, yearlyPaymentsPercentageRange should be less or equal 0.8, and more than 0'], u'location': u'body', u'name': u'yearlyPaymentsPercentageRange'}
])


# TestTenderEU


Expand Down

0 comments on commit bacd077

Please sign in to comment.