Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/a245447677040468_cpv_336'
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Jan 16, 2017
2 parents 3323e6e + b82ca65 commit b2e4767
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/openprocurement/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,8 @@ def import_data(self, raw_data, **kw):
return self

def validate_items(self, data, items):
if (data.get('revisions')[0].date if data.get('revisions') else get_now()) > CPV_ITEMS_CLASS_FROM and items and len(set([i.classification.id[:4] for i in items])) != 1:
cpv_336_group = items[0].classification.id[:3] == '336' if items else False
if not cpv_336_group and (data.get('revisions')[0].date if data.get('revisions') else get_now()) > CPV_ITEMS_CLASS_FROM and items and len(set([i.classification.id[:4] for i in items])) != 1:
raise ValidationError(u"CPV class of items should be identical")
else:
validate_cpv_group(items)
Expand Down
14 changes: 14 additions & 0 deletions src/openprocurement/api/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,20 @@ def test_create_tender_invalid(self):
{u'description': [u'CPV group of items be identical'], u'location': u'body', u'name': u'items'}
])

data = test_tender_data["items"][0].copy()
classification = data['classification'].copy()
classification["id"] = u'33600000-6'
data['classification'] = classification
test_tender_data["items"] = [data, test_tender_data["items"][0]]
response = self.app.post_json(request_path, {'data': test_tender_data}, status=422)
test_tender_data["items"] = test_tender_data["items"][1:]
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'CPV group of items be identical'], u'location': u'body', u'name': u'items'}
])

procuringEntity = test_tender_data["procuringEntity"]
data = test_tender_data["procuringEntity"].copy()
del data['kind']
Expand Down

0 comments on commit b2e4767

Please sign in to comment.