Skip to content

Commit

Permalink
Merge branch 'a200325340996959_bid_lotValues'
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Oct 24, 2016
2 parents 66a2948 + faf6358 commit b652ba1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}

setup(name='openprocurement.api',
version='2.3.23',
version='2.3.29',
description='openprocurement.api',
long_description=README,
classifiers=[
Expand Down
5 changes: 5 additions & 0 deletions src/openprocurement/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

TZ = timezone(os.environ['TZ'] if 'TZ' in os.environ else 'Europe/Kiev')
CANT_DELETE_PERIOD_START_DATE_FROM = datetime(2016, 8, 30, tzinfo=TZ)
BID_LOTVALUES_VALIDATION_FROM = datetime(2016, 10, 24, tzinfo=TZ)


def get_now():
Expand Down Expand Up @@ -669,6 +670,10 @@ def validate_lotValues(self, data, values):
tender = data['__parent__']
if tender.lots and not values:
raise ValidationError(u'This field is required.')
if tender.get('revisions') and tender['revisions'][0].date > BID_LOTVALUES_VALIDATION_FROM and values:
lots = [i.relatedLot for i in values]
if len(lots) != len(set(lots)):
raise ValidationError(u'bids don\'t allow duplicated proposals')

def validate_value(self, data, value):
if isinstance(data['__parent__'], Model):
Expand Down
6 changes: 4 additions & 2 deletions src/openprocurement/api/tests/auction.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,8 @@ def test_post_tender_auction(self):
response = self.app.patch_json('/tenders/{}/auction'.format(self.tender_id), {'data': patch_data}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], [{u'lotValues': [{u'relatedLot': [u'relatedLot should be one of lots of bid']}]}])
#self.assertEqual(response.json['errors'][0]["description"], [{u'lotValues': [{u'relatedLot': [u'relatedLot should be one of lots of bid']}]}])
self.assertEqual(response.json['errors'][0]["description"], [{u'lotValues': [u"bids don't allow duplicated proposals"]}])

patch_data['bids'][0]['lotValues'][1]['relatedLot'] = self.initial_bids[0]['lotValues'][1]['relatedLot']

Expand Down Expand Up @@ -878,7 +879,8 @@ def test_patch_tender_auction(self):
response = self.app.patch_json('/tenders/{}/auction'.format(self.tender_id), {'data': patch_data}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], [{u'lotValues': [{u'relatedLot': [u'relatedLot should be one of lots of bid']}]}])
#self.assertEqual(response.json['errors'][0]["description"], [{u'lotValues': [{u'relatedLot': [u'relatedLot should be one of lots of bid']}]}])
self.assertEqual(response.json['errors'][0]["description"], [{u'lotValues': [u"bids don't allow duplicated proposals"]}])

patch_data['bids'][0]['lotValues'][1]['relatedLot'] = self.initial_bids[0]['lotValues'][1]['relatedLot']

Expand Down
8 changes: 8 additions & 0 deletions src/openprocurement/api/tests/lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,14 @@ def test_create_tender_bidder_invalid(self):
{u'description': u"invalid literal for int() with base 10: 'contactPoint'", u'location': u'body', u'name': u'data'},
])

response = self.app.post_json(request_path, {'data': {'tenderers': [test_organization], 'lotValues': [{"value": {"amount": 500}, 'relatedLot': self.initial_lots[0]['id']}, {"value": {"amount": 500}, 'relatedLot': self.initial_lots[0]['id']}]}}, 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"bids don't allow duplicated proposals"], u'location': u'body', u'name': u'lotValues'}
])

def test_patch_tender_bidder(self):
lot_id = self.initial_lots[0]['id']
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': {'tenderers': [test_organization], 'lotValues': [{"value": {"amount": 500}, 'relatedLot': lot_id}]}})
Expand Down

0 comments on commit b652ba1

Please sign in to comment.