From 6a1b5a3d0db5246f3508a91f3065e4b177b0f86d Mon Sep 17 00:00:00 2001 From: annawzz Date: Mon, 30 Oct 2017 14:16:05 +0200 Subject: [PATCH] Add tests to check bid invalidation on tender\lot change --- .../tender/esco/tests/bid_blanks.py | 15 ++++--- openprocurement/tender/esco/tests/lot.py | 2 + .../tender/esco/tests/lot_blanks.py | 40 +++++++++++++++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/openprocurement/tender/esco/tests/bid_blanks.py b/openprocurement/tender/esco/tests/bid_blanks.py index 7bbcfae..e08fe38 100644 --- a/openprocurement/tender/esco/tests/bid_blanks.py +++ b/openprocurement/tender/esco/tests/bid_blanks.py @@ -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(): @@ -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}) @@ -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} }}}) diff --git a/openprocurement/tender/esco/tests/lot.py b/openprocurement/tender/esco/tests/lot.py index d9dc714..3148ab3 100644 --- a/openprocurement/tender/esco/tests/lot.py +++ b/openprocurement/tender/esco/tests/lot.py @@ -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 @@ -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): diff --git a/openprocurement/tender/esco/tests/lot_blanks.py b/openprocurement/tender/esco/tests/lot_blanks.py index fe6bb38..3daa064 100644 --- a/openprocurement/tender/esco/tests/lot_blanks.py +++ b/openprocurement/tender/esco/tests/lot_blanks.py @@ -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