Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/a276880397601913_set_lot_date_on…
Browse files Browse the repository at this point in the history
…_creation'
  • Loading branch information
vmaksymiv committed Mar 1, 2017
2 parents 9e71748 + ad0bea9 commit b68d226
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
6 changes: 6 additions & 0 deletions openprocurement/tender/limited/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ class Tender(ReportingTender):
procuring_entity_kinds = ['general', 'special', 'defense']
lots = ListType(ModelType(Lot), default=list(), validators=[validate_lots_uniq])

def initialize(self):
self.date = get_now()
if self.lots:
for lot in self.lots:
lot.date = get_now()

NegotiationTender = Tender


Expand Down
31 changes: 30 additions & 1 deletion openprocurement/tender/limited/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from openprocurement.tender.limited.tests.base import (
test_tender_data, test_tender_negotiation_data,
test_tender_negotiation_quick_data, BaseTenderWebTest,
test_organization, test_lots,
test_organization, test_lots
)


Expand Down Expand Up @@ -985,6 +985,35 @@ def test_changing_tender_after_award(self):
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], "Can't update tender when there is at least one award.")

def test_initial_lot_date(self):
# create tender were initial data has lots
lots = deepcopy(test_lots)*2
data = deepcopy(self.initial_data)
data['lots'] = lots
response = self.app.post_json('/tenders',
{"data": data})
tender_id = self.tender_id = response.json['data']['id']
owner_token = response.json['access']['token']

# check if initial lots have date
response = self.app.get('/tenders/{}'.format(tender_id))
lots = response.json['data']['lots']
self.assertIn('date', lots[0])
self.assertIn('date', lots[1])

# create lot
response = self.app.post_json('/tenders/{}/lots?acc_token={}'.format(tender_id, owner_token),
{'data': test_lots[0]})
self.assertEqual(response.status, '201 Created')
self.assertEqual(response.content_type, 'application/json')

# check all lots has a initial date
response = self.app.get('/tenders/{}'.format(tender_id))
lots = response.json['data']['lots']
self.assertIn('date', lots[0])
self.assertIn('date', lots[1])
self.assertIn('date', lots[2])

class TenderNegotiationQuickResourceTest(TenderNegotiationResourceTest):
initial_data = test_tender_negotiation_quick_data

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 = '2.3.21'
version = '2.3.23'

requires = [
'setuptools',
Expand Down

0 comments on commit b68d226

Please sign in to comment.