From 513456fa08d7148f998943b46af1a131162c5e29 Mon Sep 17 00:00:00 2001 From: Yaroslav Shalenyk Date: Fri, 22 May 2020 13:46:56 +0300 Subject: [PATCH] Fix tests after rebase --- .../tender/pricequotation/configure.zcml | 56 ------------------- .../tender/pricequotation/tests/base.py | 2 +- .../pricequotation/tests/tender_blanks.py | 7 +-- .../tender/pricequotation/utils.py | 20 ++++--- .../pricequotation/views/cancellation.py | 7 +-- .../tender/pricequotation/views/tender.py | 10 ++-- 6 files changed, 21 insertions(+), 81 deletions(-) delete mode 100644 src/openprocurement/tender/pricequotation/configure.zcml diff --git a/src/openprocurement/tender/pricequotation/configure.zcml b/src/openprocurement/tender/pricequotation/configure.zcml deleted file mode 100644 index 9b1bcb3a79..0000000000 --- a/src/openprocurement/tender/pricequotation/configure.zcml +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/src/openprocurement/tender/pricequotation/tests/base.py b/src/openprocurement/tender/pricequotation/tests/base.py index fda7c047ec..3d8a7fc5bc 100644 --- a/src/openprocurement/tender/pricequotation/tests/base.py +++ b/src/openprocurement/tender/pricequotation/tests/base.py @@ -81,7 +81,7 @@ def generate_bids(self, status, startend): tenderPeriod_startDate = self.now + self.periods[status][startend]["tenderPeriod"]["startDate"] bids = self.tender_document.get("bids", []) # import pdb; pdb.set_trace() - if self.initial_bids or not bids: + if self.initial_bids and not bids: self.tender_document_patch["bids"] = [] self.initial_bids_tokens = [] for position, bid in enumerate(test_bids): diff --git a/src/openprocurement/tender/pricequotation/tests/tender_blanks.py b/src/openprocurement/tender/pricequotation/tests/tender_blanks.py index e3c7336b73..431ed31444 100644 --- a/src/openprocurement/tender/pricequotation/tests/tender_blanks.py +++ b/src/openprocurement/tender/pricequotation/tests/tender_blanks.py @@ -1750,14 +1750,11 @@ def invalid_tender_conditions(self): def one_valid_bid_tender(self): tender_id = self.tender_id owner_token = self.tender_token - # switch to active.tendering - response = self.set_status( - "active.tendering" - ) # create bid self.app.authorization = ("Basic", ("broker", "")) self.app.post_json( - "/tenders/{}/bids".format(tender_id), {"data": {"tenderers": [test_organization], "value": {"amount": 500}, "requirementResponses": test_requirement_response_valid}} + "/tenders/{}/bids".format(tender_id), + {"data": {"tenderers": [test_organization], "value": {"amount": 500}, "requirementResponses": test_requirement_response_valid}} ) # switch to active.qualification self.set_status("active.qualification") diff --git a/src/openprocurement/tender/pricequotation/utils.py b/src/openprocurement/tender/pricequotation/utils.py index 622c87ed78..c91b6957ae 100644 --- a/src/openprocurement/tender/pricequotation/utils.py +++ b/src/openprocurement/tender/pricequotation/utils.py @@ -2,11 +2,7 @@ from logging import getLogger from openprocurement.api.constants import RELEASE_2020_04_19 from openprocurement.api.utils import get_now, context_unpack -from openprocurement.tender.core.utils import ( - remove_draft_bids, - cancel_tender -) - +from openprocurement.tender.core.utils import remove_draft_bids from openprocurement.tender.core.utils import get_first_revision_date @@ -25,7 +21,7 @@ def check_bids(request): add_next_award(request) -def add_contract(request, award, now=None): +def add_contract(request, award, now=None): tender = request.validated["tender"] tender.contracts.append( type(tender).contracts.model_class( @@ -49,15 +45,21 @@ def generate_contract_value(tender, award): return None -def check_cancellation_status(request, cancel_tender_method=cancel_tender): +def cancel_tender(request): + tender = request.validated["tender"] + if tender.status in ["active.tendering"]: + tender.bids = [] + tender.status = "cancelled" + + +def check_cancellation_status(request): tender = request.validated["tender"] cancellations = tender.cancellations for cancellation in cancellations: if cancellation.status == "pending": cancellation.status = "active" - if cancellation.cancellationOf == "tender": - cancel_tender_method(request) + cancel_tender(request) def check_status(request): diff --git a/src/openprocurement/tender/pricequotation/views/cancellation.py b/src/openprocurement/tender/pricequotation/views/cancellation.py index bb64a04888..c4651a7102 100644 --- a/src/openprocurement/tender/pricequotation/views/cancellation.py +++ b/src/openprocurement/tender/pricequotation/views/cancellation.py @@ -9,8 +9,8 @@ validate_tender_not_in_terminated_status, validate_cancellation_data, validate_patch_cancellation_data, - validate_cancellation_statuses_without_complaints ) +from openprocurement.tender.pricequotation.utils import cancel_tender from openprocurement.tender.pricequotation.constants import PMT @@ -37,7 +37,7 @@ def collection_post(self): cancellation.date = get_now() if cancellation.status == "active": - self.cancel_tender_method(self.request) + cancel_tender(self.request) self.request.context.cancellations.append(cancellation) if save_tender(self.request): @@ -60,7 +60,6 @@ def collection_post(self): validators=( validate_tender_not_in_terminated_status, validate_patch_cancellation_data, - validate_cancellation_statuses_without_complaints, ), permission="edit_cancellation" ) @@ -69,7 +68,7 @@ def patch(self): apply_patch(self.request, save=False, src=cancellation.serialize()) if cancellation.status == "active": - self.cancel_tender_method(self.request) + cancel_tender(self.request) if save_tender(self.request): self.LOGGER.info( diff --git a/src/openprocurement/tender/pricequotation/views/tender.py b/src/openprocurement/tender/pricequotation/views/tender.py index 8e7b453029..754020b1cb 100644 --- a/src/openprocurement/tender/pricequotation/views/tender.py +++ b/src/openprocurement/tender/pricequotation/views/tender.py @@ -2,15 +2,14 @@ from openprocurement.api.utils import context_unpack, json_view from openprocurement.tender.core.utils import\ save_tender, optendersresource, apply_patch -from openprocurement.tender.core.validation import ( - validate_tender_not_in_terminated_status, - validate_tender_change_status_permission, -) +from openprocurement.tender.core.validation import\ + validate_tender_not_in_terminated_status from openprocurement.tender.belowthreshold.views.tender import TenderResource from openprocurement.tender.pricequotation.constants import PMT from openprocurement.tender.pricequotation.utils import check_status -from openprocurement.tender.pricequotation.validation import validate_patch_tender_data +from openprocurement.tender.pricequotation.validation import\ + validate_patch_tender_data @optendersresource( @@ -27,7 +26,6 @@ class PriceQuotationTenderResource(TenderResource): validators=( validate_patch_tender_data, validate_tender_not_in_terminated_status, - validate_tender_change_status_permission, ), permission="edit_tender", )