Skip to content

Commit

Permalink
Merge branch 'a469042841544582_remove_no_auction'
Browse files Browse the repository at this point in the history
  • Loading branch information
annawzz committed Nov 9, 2017
2 parents 31b42bf + 2eaead4 commit 1b5defa
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 94 deletions.
1 change: 0 additions & 1 deletion openprocurement/tender/esco/models.py
Expand Up @@ -413,7 +413,6 @@ class Options:
yearlyPaymentsPercentageRange = DecimalType(required=True, default=Decimal('0.8'),
min_value=Decimal('0'), max_value=Decimal('1'),
precision=-5)
submissionMethodDetails = StringType(default="quick(mode:no-auction)") # TODO: temporary decision, while esco auction is not ready. Remove after adding auction. Remove function "check_submission_method_details" in openprocurement.tender.esco.subscribers
noticePublicationDate = IsoDateTimeType()

create_accreditation = 3
Expand Down
16 changes: 0 additions & 16 deletions openprocurement/tender/esco/subscribers.py
Expand Up @@ -24,19 +24,3 @@ def tender_init_handler(event):
if tender.lots:
for lot in tender.lots:
lot.date = now

check_submission_method_details(tender)


# TODO: temporary decision, while esco auction is not ready. Remove after adding auction. Remove field 'submissionMethodDetails' in openprocurement.tender.esco.models.Tender
from openprocurement.api.utils import error_handler

def check_submission_method_details(tender):
if tender.submissionMethodDetails != "quick(mode:no-auction)":
tender.__parent__.request.errors.add(
'data',
'submissionMethodDetails',
'Invalid field value "{0}". Only "quick(mode:no-auction)" is allowed while auction module for this type of procedure is not fully implemented'.
format(tender.submissionMethodDetails))
tender.__parent__.request.errors.status = 403
raise error_handler(tender.__parent__.request.errors)
5 changes: 0 additions & 5 deletions openprocurement/tender/esco/tests/tender.py
Expand Up @@ -70,7 +70,6 @@ class TenderESCOTest(BaseESCOWebTest):
class TestTenderEU(BaseESCOContentWebTest, TenderResourceTestMixin, TenderUAResourceTestMixin):
""" ESCO tender test """
initialize_initial_data = False
test_tender_data['submissionMethodDetails'] = "quick(mode:no-auction)" # TODO: remove this line after adding auction
initial_data = test_tender_data
# for passing test from TenderUAResourceTestMixin
initial_data['minValue'] = {"amount": 0}
Expand All @@ -89,10 +88,6 @@ class TestTenderEU(BaseESCOContentWebTest, TenderResourceTestMixin, TenderUAReso
test_invalid_bid_tender_features = snitch(invalid_bid_tender_features)
test_invalid_bid_tender_lot = snitch(invalid_bid_tender_lot)

# TODO: remove this test after adding auction
from openprocurement.tender.esco.tests.tender_blanks import tender_submission_method_details_no_auction_only
test_tender_submission_method_details_no_auction_only = snitch(tender_submission_method_details_no_auction_only)


class TestTenderEUProcess(BaseESCOContentWebTest):

Expand Down
53 changes: 2 additions & 51 deletions openprocurement/tender/esco/tests/tender_blanks.py
Expand Up @@ -961,7 +961,7 @@ def tender_with_nbu_discount_rate(self):
u'procurementMethodType', u'id', u'dateModified', u'tenderID',
u'status', u'enquiryPeriod', u'tenderPeriod', u'auctionPeriod',
u'complaintPeriod', u'items', u'minValue', u'owner', u'minimalStepPercentage',
u'procuringEntity', u'next_check', u'procurementMethod', u'submissionMethodDetails', # TODO: remove u'submissionMethodDetails' from set after adding auction
u'procuringEntity', u'next_check', u'procurementMethod',
u'awardCriteria', u'submissionMethod', u'title', u'title_en', u'date', u'NBUdiscountRate',
u'fundingKind', u'yearlyPaymentsPercentageRange']))
self.assertNotEqual(data['id'], tender['id'])
Expand Down Expand Up @@ -1293,60 +1293,11 @@ def create_tender_generated(self):
tender.pop('noticePublicationDate')
self.assertEqual(set(tender), set([
u'procurementMethodType', u'id', u'dateModified', u'tenderID',
u'status', u'enquiryPeriod', u'tenderPeriod', u'auctionPeriod', u'submissionMethodDetails', # TODO: remove u'submissionMethodDetails' from set after adding auction
u'status', u'enquiryPeriod', u'tenderPeriod', u'auctionPeriod',
u'complaintPeriod', u'items', u'minValue', u'owner', u'minimalStepPercentage',
u'procuringEntity', u'next_check', u'procurementMethod', u'NBUdiscountRate',
u'awardCriteria', u'submissionMethod', u'title', u'title_en', u'date',
u'fundingKind', u'yearlyPaymentsPercentageRange']))
self.assertNotEqual(data['id'], tender['id'])
self.assertNotEqual(data['doc_id'], tender['id'])
self.assertNotEqual(data['tenderID'], tender['tenderID'])


# TODO: remove this test after adding auction
def tender_submission_method_details_no_auction_only(self):
response = self.app.get('/tenders')
self.assertEqual(response.status, '200 OK')
self.assertEqual(len(response.json['data']), 0)

my_data = deepcopy(self.initial_data)
my_data['submissionMethodDetails'] = 'quick(mode:fast-forward)'

response = self.app.post_json('/tenders', {"data": my_data}, status=403)
self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'], [
{u'description':
u'Invalid field value "quick(mode:fast-forward)". Only "quick(mode:no-auction)" is allowed while auction module for this type of procedure is not fully implemented',
u'location': u'data',
u'name': u'submissionMethodDetails'}
])

response = self.app.post_json('/tenders', {"data": self.initial_data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data']['submissionMethodDetails'], "quick(mode:no-auction)")
tender = response.json['data']
self.tender_id = response.json['data']['id']
owner_token = response.json['access']['token']

response = self.app.get('/tenders/{}'.format(tender['id']))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(set(response.json['data']), set(tender))
self.assertEqual(response.json['data'], tender)
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(
tender['id'], owner_token), {'data': {'submissionMethodDetails': "quick(mode:fast-forward)"}}, status=403)

self.assertEqual(response.status, '403 Forbidden')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'], [
{u'description': u'Invalid field value "quick(mode:fast-forward)". Only "quick(mode:no-auction)" is allowed while auction module for this type of procedure is not fully implemented',
u'location': u'data',
u'name': u'submissionMethodDetails'}
])

response = self.app.get('/tenders/{}'.format(tender['id']))
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data']['submissionMethodDetails'], "quick(mode:no-auction)")
21 changes: 0 additions & 21 deletions openprocurement/tender/esco/views/tender.py
Expand Up @@ -12,30 +12,9 @@
from openprocurement.tender.openua.validation import validate_patch_tender_ua_data


# TODO: remove this validator after adding auction
def validate_submission_method_details(request):
submission_method_details = request.validated['data'].get("submissionMethodDetails", request.context.submissionMethodDetails)
if submission_method_details != request.context.submissionMethodDetails and submission_method_details != 'quick(mode:no-auction)':
request.errors.add(
'data',
'submissionMethodDetails',
'Invalid field value "{0}". Only "quick(mode:no-auction)" is allowed while auction module for this type of procedure is not fully implemented'.
format(submission_method_details))
request.errors.status = 403
raise error_handler(request.errors)


@optendersresource(name='esco:Tender',
path='/tenders/{tender_id}',
procurementMethodType='esco',
description="Open Contracting compatible data exchange format. See http://ocds.open-contracting.org/standard/r/master/#tender for more info")
class TenderESCOResource(TenderEUResource):
""" Resource handler for Tender ESCO """

# TODO: remove this method after adding auction
patch = json_view(content_type="application/json",
validators=(validate_patch_tender_ua_data,
validate_tender_status_update_in_terminated_status,
validate_tender_status_update_not_in_pre_qualificaton,
validate_submission_method_details),
permission='edit_tender')(TenderEUResource.patch)

0 comments on commit 1b5defa

Please sign in to comment.