Skip to content

Commit

Permalink
Add tests to check bid invalidation on tender\lot change
Browse files Browse the repository at this point in the history
  • Loading branch information
annawzz committed Oct 30, 2017
1 parent 4cad1b8 commit 6a1b5a3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
15 changes: 9 additions & 6 deletions openprocurement/tender/esco/tests/bid_blanks.py
Expand Up @@ -786,12 +786,15 @@ def bids_invalidation_on_tender_change(self):
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']['status'], 'pending')

# update tender. we can set value that is less than a value in bids as
# they will be invalidated by this request
# update tender. we can set yearlyPaymentsPercentageRange value
# that is less than a value in bids as they will be invalidated by this request
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(
self.tender_id, self.tender_token), {"data": {"description": "new description"}})
self.tender_id, self.tender_token), {'data': {
'yearlyPaymentsPercentageRange': 0.7,
'fundingKind': 'budget'}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']["description"], "new description")
self.assertEqual(response.json['data']["yearlyPaymentsPercentageRange"], 0.7)
self.assertEqual(response.json['data']["fundingKind"], "budget")

# check bids status
for bid_id, token in bids_access.items():
Expand Down Expand Up @@ -825,7 +828,7 @@ def bids_invalidation_on_tender_change(self):
data = deepcopy(self.test_bids_data[0])
data['value'] = {
"annualCostsReduction": [200] * 21,
"yearlyPaymentsPercentage": 0.8,
"yearlyPaymentsPercentage": 0.7,
"contractDuration": {"years": 10, "days": 15}
}
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': data})
Expand All @@ -839,7 +842,7 @@ def bids_invalidation_on_tender_change(self):
'tenderers': self.test_bids_data[1]['tenderers'],
"value": {
"annualCostsReduction": [200] * 21,
"yearlyPaymentsPercentage": 0.8,
"yearlyPaymentsPercentage": 0.7,
"contractDuration": {"years": 10, "days": 15}
}}})

Expand Down
2 changes: 2 additions & 0 deletions openprocurement/tender/esco/tests/lot.py
Expand Up @@ -59,6 +59,7 @@
# TenderLotBidResourceTest
create_tender_bid_invalid,
patch_tender_bid,
bids_invalidation_on_lot_change,
)
from openprocurement.tender.esco.utils import to_decimal

Expand Down Expand Up @@ -137,6 +138,7 @@ class TenderLotBidResourceTest(BaseESCOContentWebTest):

test_create_tender_bid_invalid = snitch(create_tender_bid_invalid)
test_patch_tender_bid = snitch(patch_tender_bid)
test_bids_invalidation_on_lot_change = snitch(bids_invalidation_on_lot_change)


class TenderLotFeatureBidResourceTest(BaseESCOContentWebTest):
Expand Down
40 changes: 40 additions & 0 deletions openprocurement/tender/esco/tests/lot_blanks.py
Expand Up @@ -734,6 +734,46 @@ def patch_tender_bid(self):
self.assertEqual(response.json['errors'][0]["description"],
"Can't update bid in current (unsuccessful) tender status")


def bids_invalidation_on_lot_change(self):
bids_access = {}

lot_id = self.initial_lots[0]['id']
response = self.app.post_json('/tenders/{}/bids'.format(self.tender_id), {'data': {
'selfEligible': True, 'selfQualified': True,
'tenderers': self.test_bids_data[0]["tenderers"],
'lotValues': [{"value": self.test_bids_data[0]['value'], 'relatedLot': lot_id}]}})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
bid = response.json['data']
bid_token = response.json['access']['token']

# check initial status
response = self.app.get('/tenders/{}/bids/{}?acc_token={}'.format(
self.tender_id, bid['id'], bid_token))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']['status'], 'pending')

# update tender (with fundingKind budget we can set not 0.8 in yppr field)
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(
self.tender_id, self.tender_token), {'data': {'fundingKind': 'budget'}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']["fundingKind"], "budget")

# update lot. we can set yppr that is less than a value in bids as
# they will be invalidated by this request
response = self.app.patch_json('/tenders/{}/lots/{}?acc_token={}'.format(
self.tender_id, lot_id, self.tender_token), {"data": {"yearlyPaymentsPercentageRange": 0.1}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']["yearlyPaymentsPercentageRange"], 0.1)

# check bids status
response = self.app.get('/tenders/{}/bids/{}?acc_token={}'.format(
self.tender_id, bid['id'], bid_token))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']['status'], 'invalid')


# TenderLotFeatureBidResourceTest


Expand Down

0 comments on commit 6a1b5a3

Please sign in to comment.