Skip to content

Commit

Permalink
Fixed fields values
Browse files Browse the repository at this point in the history
  • Loading branch information
kroman0 committed Jan 16, 2015
1 parent c4f4503 commit f9290b7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
13 changes: 12 additions & 1 deletion src/openprocurement/api/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


LOGGER = logging.getLogger(__name__)
SCHEMA_VERSION = 12
SCHEMA_VERSION = 13
SCHEMA_DOC = 'openprocurement_schema'


Expand Down Expand Up @@ -459,3 +459,14 @@ def from11to12(db):
if changed:
doc['dateModified'] = get_now().isoformat()
db.save(doc)


def from12to13(db):
results = db.view('tenders/all', include_docs=True)
for i in results:
doc = i.doc
doc['procurementMethod'] = 'open'
doc['awardCriteria'] = 'lowestCost'
doc['submissionMethod'] = 'electronicAuction'
doc['dateModified'] = get_now().isoformat()
db.save(doc)
6 changes: 3 additions & 3 deletions src/openprocurement/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,15 @@ def __local_roles__(self):
tenderID = StringType() # TenderID should always be the same as the OCID. It is included to make the flattened data structure more convenient.
items = ListType(ModelType(Item), required=True, min_size=1) # 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.
value = ModelType(Value, required=True) # The total estimated value of the procurement.
procurementMethod = StringType(choices=['Open', 'Selective', 'Limited'], default='Open') # Specify tendering method as per GPA definitions of Open, Selective, Limited (http://www.wto.org/english/docs_e/legal_e/rev-gpr-94_01_e.htm)
procurementMethod = StringType(choices=['open', 'selective', 'limited'], default='open') # Specify tendering method as per GPA definitions of Open, Selective, Limited (http://www.wto.org/english/docs_e/legal_e/rev-gpr-94_01_e.htm)
procurementMethodRationale = StringType() # Justification of procurement method, especially in the case of Limited tendering.
procurementMethodRationale_en = StringType()
procurementMethodRationale_ru = StringType()
awardCriteria = StringType(choices=['Lowest Cost', 'Best Proposal', 'Best Value to Government', 'Single bid only'], default='Lowest Cost') # Specify the selection criteria, by lowest cost,
awardCriteria = StringType(choices=['lowestCost', 'bestProposal', 'bestValueToGovernment', 'singleBidOnly'], default='lowestCost') # Specify the selection criteria, by lowest cost,
awardCriteriaDetails = StringType() # Any detailed or further information on the selection criteria.
awardCriteriaDetails_en = StringType()
awardCriteriaDetails_ru = StringType()
submissionMethod = StringType(choices=['Electronic Auction', 'Electronic Submission', 'Written', 'In Person'], default='Electronic Auction') # Specify the method by which bids must be submitted, in person, written, or electronic auction
submissionMethod = StringType(choices=['electronicAuction', 'electronicSubmission', 'written', 'inPerson'], default='electronicAuction') # Specify the method by which bids must be submitted, in person, written, or electronic auction
submissionMethodDetails = StringType() # Any detailed or further information on the submission method.
submissionMethodDetails_en = StringType()
submissionMethodDetails_ru = StringType()
Expand Down
16 changes: 16 additions & 0 deletions src/openprocurement/api/tests/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,22 @@ def test_migrate_from11to12(self):
self.app.authorization = ('Basic', ('broker05', ''))
self.app.post_json('/tenders', {'data': test_tender_data}, status=403)

def test_migrate_from12to13(self):
set_db_schema_version(self.db, 12)
data = {
'doc_type': 'Tender',
'procurementMethod': 'Open',
'awardCriteria': 'Lowest Cost',
'submissionMethod': 'Electronic Auction',
}
_id, _rev = self.db.save(data)
item = self.db.get(_id)
migrate_data(self.db, 13)
migrated_item = self.db.get(_id)
self.assertEqual('open', migrated_item['procurementMethod'])
self.assertEqual('lowestCost', migrated_item['awardCriteria'])
self.assertEqual('electronicAuction', migrated_item['submissionMethod'])


def suite():
suite = unittest.TestSuite()
Expand Down
2 changes: 1 addition & 1 deletion src/openprocurement/api/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_create_tender_invalid(self):
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertIn({u'description': [u"Value must be one of ['Open', 'Selective', 'Limited']."], u'location': u'body', u'name': u'procurementMethod'}, response.json['errors'])
self.assertIn({u'description': [u"Value must be one of ['open', 'selective', 'limited']."], u'location': u'body', u'name': u'procurementMethod'}, response.json['errors'])
self.assertIn({u'description': [u'This field is required.'], u'location': u'body', u'name': u'tenderPeriod'}, response.json['errors'])
self.assertIn({u'description': [u'This field is required.'], u'location': u'body', u'name': u'minimalStep'}, response.json['errors'])
self.assertIn({u'description': [u'This field is required.'], u'location': u'body', u'name': u'items'}, response.json['errors'])
Expand Down

0 comments on commit f9290b7

Please sign in to comment.