Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/a208908924249389_default_procure…
Browse files Browse the repository at this point in the history
…mentMethod'
  • Loading branch information
vmaksymiv committed Nov 10, 2016
2 parents a1857a0 + 1ec67f2 commit db01f67
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
4 changes: 3 additions & 1 deletion openprocurement/tender/competitivedialogue/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ class Tender(CompetitiveDialogEU):

stage_2_roles = {
'plain': plain_role,
'create': (blacklist('owner_token', 'tenderPeriod', '_attachments', 'revisions', 'dateModified', 'doc_id', 'bids', 'documents', 'awards', 'questions', 'complaints', 'auctionUrl', 'status', 'auctionPeriod', 'awardPeriod', 'awardCriteria', 'submissionMethod', 'cancellations') + schematics_embedded_role),
'create': (blacklist('owner_token', 'tenderPeriod', '_attachments', 'revisions', 'dateModified', 'doc_id', 'bids', 'documents', 'awards', 'questions', 'complaints', 'auctionUrl', 'status', 'auctionPeriod', 'awardPeriod', 'awardCriteria', 'submissionMethod', 'cancellations', 'procurementMethod') + schematics_embedded_role),
'edit': whitelist('tenderPeriod'),
'edit_draft': whitelist('status'), # only bridge must change only status
'edit_'+STAGE2_STATUS: whitelist('tenderPeriod', 'status'),
Expand Down Expand Up @@ -412,6 +412,7 @@ class Tender(BaseTenderEU):
'unsuccessful', STAGE2_STATUS],
default='active.tendering')
lots = ListType(ModelType(LotStage2EU), default=list(), validators=[validate_lots_uniq])
procurementMethod = StringType(choices=['open', 'selective', 'limited'], default='selective')

# The goods and services to be purchased, broken into line items wherever possible. Items should not be duplicated, but a quantity of 2 specified instead.
items = ListType(ModelType(ItemStage2EU), required=True, min_size=1, validators=[validate_cpv_group,
Expand Down Expand Up @@ -453,6 +454,7 @@ class Tender(BaseTenderUA):
items = ListType(ModelType(ItemStage2UA), required=True, min_size=1, validators=[validate_cpv_group,
validate_items_uniq])
features = ListType(ModelType(Feature), validators=[validate_features_uniq])
procurementMethod = StringType(choices=['open', 'selective', 'limited'], default='selective')

create_accreditation = 'c'

Expand Down
52 changes: 52 additions & 0 deletions openprocurement/tender/competitivedialogue/tests/stage2/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,32 @@ def set_tender_status(self, tender, token, status):
self.app.authorization = auth
return response

def test_invalid_procurementMethod(self):
""" Create create or edit field procurementMethod second stage """
self.app.authorization = ('Basic', ('competitive_dialogue', ''))
data = deepcopy(test_tender_stage2_data_eu)
del data['procurementMethod']
response = self.app.post_json('/tenders', {'data': data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
tender = response.json['data']
token = response.json['access']['token']
self.assertEqual(response.json['data']['procurementMethod'], 'selective')

# Try edit
self.app.authorization = ('Basic', ('broker', ''))
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender['id'], token),
{'data': {'procurementMethod': 'open', 'status': 'active.tendering'}})
self.assertEqual(response.json['data']['procurementMethod'], 'selective')

# Try create and send wrong procurementMethod
self.app.authorization = ('Basic', ('competitive_dialogue', ''))
data['procurementMethod'] = 'open'
response = self.app.post_json('/tenders', {'data': data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data']['procurementMethod'], 'selective')

def test_listing(self):
self.app.authorization = ('Basic', ('competitive_dialogue', ''))
response = self.app.get('/tenders')
Expand Down Expand Up @@ -1196,6 +1222,32 @@ def set_tender_status(self, tender, token, status):
self.app.authorization = auth
return response

def test_invalid_procurementMethod(self):
""" Create create or edit field procurementMethod second stage """
self.app.authorization = ('Basic', ('competitive_dialogue', ''))
data = deepcopy(test_tender_stage2_data_ua)
del data['procurementMethod']
response = self.app.post_json('/tenders', {'data': data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
tender = response.json['data']
token = response.json['access']['token']
self.assertEqual(response.json['data']['procurementMethod'], 'selective')

# Try edit
self.app.authorization = ('Basic', ('broker', ''))
response = self.app.patch_json('/tenders/{}?acc_token={}'.format(tender['id'], token),
{'data': {'procurementMethod': 'open', 'status': 'active.tendering'}})
self.assertEqual(response.json['data']['procurementMethod'], 'selective')

# Try create and send wrong procurementMethod
self.app.authorization = ('Basic', ('competitive_dialogue', ''))
data['procurementMethod'] = 'open'
response = self.app.post_json('/tenders', {'data': data})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['data']['procurementMethod'], 'selective')

def test_empty_listing(self):
response = self.app.get('/tenders')
self.assertEqual(response.status, '200 OK')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '1.0'
version = '1.0.2'

requires = [
'setuptools'
Expand Down

0 comments on commit db01f67

Please sign in to comment.