Skip to content

Commit

Permalink
Merge branch 'master' of github.com:openprocurement/openprocurement.t…
Browse files Browse the repository at this point in the history
…ender.openua
  • Loading branch information
kroman0 committed Mar 22, 2016
2 parents 3d09cdd + 7ec6755 commit 0740aa5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions openprocurement/tender/openua/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ def validate_value(self, data, value):
if lot.get('value').valueAddedTaxIncluded != value.valueAddedTaxIncluded:
raise ValidationError(u"valueAddedTaxIncluded of bid should be identical to valueAddedTaxIncluded of value of lot")

def validate_relatedLot(self, data, relatedLot):
if isinstance(data['__parent__'], Model) and (data['__parent__'].status not in ('invalid')) and relatedLot not in [i.id for i in get_tender(data['__parent__']).lots]:
raise ValidationError(u"relatedLot should be one of lots")

class Bid(BaseBid):

Expand Down
45 changes: 45 additions & 0 deletions openprocurement/tender/openua/tests/lot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,51 @@ def test_2lot_1bid_0com_1can(self):
response = self.app.patch_json('/tenders/{}'.format(tender_id), {"data": {"id": tender_id}})
self.assertEqual(response.json['data']['status'], 'unsuccessful')

def test_2lot_2bid_1lot_del(self):
self.app.authorization = ('Basic', ('broker', ''))
# create tender
response = self.app.post_json('/tenders', {"data": test_tender_ua_data})
tender_id = self.tender_id = response.json['data']['id']
owner_token = response.json['access']['token']
lots = []
for lot in 2 * test_lots:
# add lot
response = self.app.post_json('/tenders/{}/lots?acc_token={}'.format(tender_id, owner_token), {'data': test_lots[0]})
self.assertEqual(response.status, '201 Created')
lots.append(response.json['data']['id'])
self.initial_lots = lots
# add item
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, owner_token), {"data": {"items": [test_tender_ua_data['items'][0] for i in lots]}})
# add relatedLot for item
# response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender_id, owner_token), {"data": {"items": [{'relatedLot': i} for i in lots[]]}})
# self.assertEqual(response.status, '200 OK')
# switch to active.tendering
response = self.set_status('active.tendering', {"lots": [
{"auctionPeriod": {"startDate": (get_now() + timedelta(days=16)).isoformat()}}
for i in lots
]})
# create bid

bids = []
self.app.authorization = ('Basic', ('broker', ''))
response = self.app.post_json('/tenders/{}/bids'.format(tender_id), {'data': {'selfEligible': True, 'selfQualified': True,
'tenderers': [test_tender_ua_data["procuringEntity"]], 'lotValues': [
{"value": {"amount": 500}, 'relatedLot': lot_id}
for lot_id in lots
]}})
bids.append(response.json)
# create second bid
self.app.authorization = ('Basic', ('broker', ''))
response = self.app.post_json('/tenders/{}/bids'.format(tender_id), {'data': {'selfEligible': True, 'selfQualified': True,
'tenderers': [test_tender_ua_data["procuringEntity"]], 'lotValues': [
{"value": {"amount": 500}, 'relatedLot': lot_id}
for lot_id in lots
]}})
bids.append(response.json)
response = self.app.delete('/tenders/{}/lots/{}?acc_token={}'.format(self.tender_id, lots[0], owner_token))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')


def test_2lot_1bid_2com_1win(self):
# create tender
Expand Down

0 comments on commit 0740aa5

Please sign in to comment.