Skip to content

Commit

Permalink
Merge pull request #106 from VDigitall/a563879808284502_disable_99999…
Browse files Browse the repository at this point in the history
…9-9_additional_classification_required

Disable require additionalClassification for classification.id == 999…
  • Loading branch information
kroman0 committed Mar 14, 2018
2 parents 5c9167b + 6d20e7e commit c681987
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
4 changes: 2 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ index = https://pypi.python.org/simple

[sources]
openprocurement.api = git https://github.com/openprocurement/openprocurement.api.git branch=production
openprocurement.tender.core = git https://github.com/openprocurement/openprocurement.tender.core.git branch=production
openprocurement.tender.belowthreshold = git https://github.com/openprocurement/openprocurement.tender.belowthreshold.git branch=production
openprocurement.tender.core = git https://github.com/openprocurement/openprocurement.tender.core.git branch=a563879808284502_disable_999999-9_additional_classification_required
openprocurement.tender.belowthreshold = git https://github.com/openprocurement/openprocurement.tender.belowthreshold.git branch=a563879808284502_disable_999999-9_additional_classification_required
openprocurement.tender.openua = git https://github.com/openprocurement/openprocurement.tender.openua.git branch=production

[test]
Expand Down
50 changes: 42 additions & 8 deletions openprocurement/tender/limited/tests/tender_blanks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
from openprocurement.api.utils import get_now
from openprocurement.api.constants import ROUTE_PREFIX, CPV_ITEMS_CLASS_FROM

from openprocurement.tender.core.constants import (
NOT_REQUIRED_ADDITIONAL_CLASSIFICATION_FROM
)
from openprocurement.tender.belowthreshold.tests.base import test_organization


Expand Down Expand Up @@ -422,17 +425,22 @@ def create_tender_invalid(self):
if get_now() > CPV_ITEMS_CLASS_FROM:
cpv_code = self.initial_data["items"][0]['classification']['id']
self.initial_data["items"][0]['classification']['id'] = '99999999-9'
response = self.app.post_json(request_path, {'data': self.initial_data}, status=422)
status = 422 if get_now() < NOT_REQUIRED_ADDITIONAL_CLASSIFICATION_FROM else 201
response = self.app.post_json(request_path, {'data': self.initial_data}, status=status)
self.initial_data["items"][0]["additionalClassifications"] = data
if get_now() > CPV_ITEMS_CLASS_FROM:
self.initial_data["items"][0]['classification']['id'] = cpv_code
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'additionalClassifications': [u'This field is required.']}], u'location': u'body',
u'name': u'items'}
])
if status == 201:
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
else:
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'additionalClassifications': [u'This field is required.']}], u'location': u'body',
u'name': u'items'}
])

data = self.initial_data["items"][0]["additionalClassifications"][0]["scheme"]
self.initial_data["items"][0]["additionalClassifications"][0]["scheme"] = 'Не ДКПП'
Expand Down Expand Up @@ -618,6 +626,32 @@ def create_tender(self):
self.assertNotIn('streetAddress', response.json['data']['items'][0]['deliveryAddress'])
self.assertNotIn('region', response.json['data']['items'][0]['deliveryAddress'])

initial_data = deepcopy(self.initial_data)
initial_data['items'][0]['classification']['id'] = "99999999-9"
additional_classification =\
initial_data['items'][0].pop('additionalClassifications')
additional_classification[0]['scheme'] = "specialNorms"
if get_now() > NOT_REQUIRED_ADDITIONAL_CLASSIFICATION_FROM:
response = self.app.post_json('/tenders', {"data": initial_data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
tender = response.json['data']
self.assertEqual(tender['items'][0]['classification']['id'],
'99999999-9')
self.assertNotIn('additionalClassifications', tender['items'][0])

initial_data['items'][0]['additionalClassifications'] =\
additional_classification
response = self.app.post_json('/tenders', {"data": initial_data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
tender = response.json['data']
self.assertEqual(tender['items'][0]['classification']['id'], '99999999-9')
self.assertEqual(
tender['items'][0]['additionalClassifications'],
additional_classification
)


def patch_tender(self):
response = self.app.get('/tenders')
Expand Down

0 comments on commit c681987

Please sign in to comment.