Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion openprocurement/auctions/flash/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
BIDDER_TIME = timedelta(minutes=3 * 3)
SERVICE_TIME = timedelta(minutes=5 + 3 + 3)
AUCTION_STAND_STILL_TIME = timedelta(minutes=15)

CANT_DELETE_PERIOD_START_DATE_FROM = datetime(2017, 3, 18, tzinfo=TZ)

def read_json(name):
import os.path
Expand Down Expand Up @@ -59,6 +59,9 @@ class AuctionPeriodEndRequired(PeriodEndRequired):
def validate_startDate(self, data, period):
if period and data.get('endDate') and data.get('endDate') < period:
raise ValidationError(u"period should begin before its end")
auction = get_auction(data['__parent__'])
if auction.get('revisions') and auction['revisions'][0].date > CANT_DELETE_PERIOD_START_DATE_FROM and not period:
raise ValidationError([u'This field cannot be deleted'])


def calc_auction_end_time(bids, start):
Expand Down
20 changes: 0 additions & 20 deletions openprocurement/auctions/flash/tests/chronograph.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@

class AuctionSwitchtenderingResourceTest(BaseAuctionWebTest):

def test_switch_to_tendering_by_enquiryPeriod_endDate(self):
self.app.authorization = ('Basic', ('chronograph', ''))
response = self.app.patch_json('/auctions/{}'.format(self.auction_id), {'data': {'id': self.auction_id}})
self.assertEqual(response.status, '200 OK')
date_1 = response.json['data']['date']
self.assertNotEqual(response.json['data']["status"], "active.tendering")
self.set_status('active.tendering', {'status': 'active.enquiries', "tenderPeriod": {"startDate": None}})
response = self.app.patch_json('/auctions/{}'.format(self.auction_id), {'data': {'id': self.auction_id}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']["status"], "active.tendering")
self.assertNotEqual(date_1, response.json['data']['date'])

def test_switch_to_tendering_by_auctionPeriod_startDate(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тести мають бути часозалежні

self.set_status('active.tendering', {'status': 'active.enquiries', "tenderPeriod": {}})
self.app.authorization = ('Basic', ('chronograph', ''))
Expand All @@ -30,14 +18,6 @@ def test_switch_to_tendering_by_auctionPeriod_startDate(self):
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']["status"], "active.tendering")

def test_switch_to_tendering_auctionPeriod(self):
self.set_status('active.tendering', {'status': 'active.enquiries', "tenderPeriod": {"startDate": None}})
self.app.authorization = ('Basic', ('chronograph', ''))
response = self.app.patch_json('/auctions/{}'.format(self.auction_id), {'data': {'id': self.auction_id}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.json['data']["status"], "active.tendering")
self.assertIn('auctionPeriod', response.json['data'])


class AuctionSwitchQualificationResourceTest(BaseAuctionWebTest):
initial_status = 'active.tendering'
Expand Down
49 changes: 41 additions & 8 deletions openprocurement/auctions/flash/tests/tender.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from openprocurement.api.utils import ROUTE_PREFIX
from openprocurement.api.models import get_now, SANDBOX_MODE
from openprocurement.auctions.flash.models import Auction
from openprocurement.auctions.flash.models import Auction, CANT_DELETE_PERIOD_START_DATE_FROM
from openprocurement.auctions.flash.tests.base import test_auction_data, test_organization, BaseWebTest, BaseAuctionWebTest


Expand Down Expand Up @@ -779,6 +779,7 @@ def test_auction_features_invalid(self):

def test_auction_features(self):
data = test_auction_data.copy()
data['procuringEntity']['contactPoint']['faxNumber'] = u"0440000000"
item = data['items'][0].copy()
item['id'] = "1"
data['items'] = [item]
Expand Down Expand Up @@ -850,9 +851,11 @@ def test_auction_features(self):
self.assertIn('features', response.json['data'])
self.assertNotIn('relatedItem', response.json['data']['features'][0])

response = self.app.patch_json('/auctions/{}'.format(auction['id']), {'data': {'tenderPeriod': {'startDate': None}}})
response = self.app.patch_json('/auctions/{}'.format(auction['id']),
{'data': {'procuringEntity': {'contactPoint': {'faxNumber': None}}}})
self.assertEqual(response.status, '200 OK')
self.assertIn('features', response.json['data'])
self.assertNotIn('faxNumber', response.json['data']['procuringEntity']['contactPoint'])

response = self.app.patch_json('/auctions/{}'.format(auction['id']), {'data': {'features': []}})
self.assertEqual(response.status, '200 OK')
Expand Down Expand Up @@ -892,11 +895,13 @@ def test_patch_tender_jsonpatch(self):
self.assertEqual(response.content_type, 'application/json')

def test_patch_auction(self):
data = test_auction_data.copy()
data['procuringEntity']['contactPoint']['faxNumber'] = u"0440000000"
response = self.app.get('/auctions')
self.assertEqual(response.status, '200 OK')
self.assertEqual(len(response.json['data']), 0)

response = self.app.post_json('/auctions', {'data': test_auction_data})
response = self.app.post_json('/auctions', {'data': data})
self.assertEqual(response.status, '201 Created')
auction = response.json['data']
owner_token = response.json['access']['token']
Expand All @@ -918,13 +923,13 @@ def test_patch_auction(self):
self.assertNotIn('kind', response.json['data']['procuringEntity'])

response = self.app.patch_json('/auctions/{}'.format(
auction['id']), {'data': {'tenderPeriod': {'startDate': None}}})
auction['id']), {'data': {'procuringEntity': {'contactPoint': {'faxNumber': None}}}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertNotIn('startDate', response.json['data']['tenderPeriod'])
self.assertNotIn('faxNumber', response.json['data']['procuringEntity']['contactPoint'])

response = self.app.patch_json('/auctions/{}'.format(
auction['id']), {'data': {'tenderPeriod': {'startDate': auction['enquiryPeriod']['endDate']}}})
auction['id']), {'data': {'procuringEntity': {'contactPoint': {'faxNumber': u"0440000000"}}}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
self.assertIn('startDate', response.json['data']['tenderPeriod'])
Expand Down Expand Up @@ -953,12 +958,12 @@ def test_patch_auction(self):
self.assertEqual(revisions[-1][u'changes'][0]['path'], u'/procurementMethodRationale')

response = self.app.patch_json('/auctions/{}'.format(
auction['id']), {'data': {'items': [test_auction_data['items'][0]]}})
auction['id']), {'data': {'items': [data['items'][0]]}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')

response = self.app.patch_json('/auctions/{}'.format(
auction['id']), {'data': {'items': [{}, test_auction_data['items'][0]]}})
auction['id']), {'data': {'items': [{}, data['items'][0]]}})
self.assertEqual(response.status, '200 OK')
self.assertEqual(response.content_type, 'application/json')
item0 = response.json['data']['items'][0]
Expand Down Expand Up @@ -1023,6 +1028,34 @@ def test_patch_auction(self):
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['errors'][0]["description"], "Can't update auction in current (complete) status")

@unittest.skipIf(get_now() < CANT_DELETE_PERIOD_START_DATE_FROM,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тести мають бути часозалежні

"Can`t delete period start date only from {}".format(CANT_DELETE_PERIOD_START_DATE_FROM))
def test_required_field_deletion(self):
response = self.app.post_json('/auctions', {'data': test_auction_data})
self.assertEqual(response.status, '201 Created')
tender = response.json['data']

# TODO: Test all the required fields
response = self.app.patch_json('/auctions/{}'.format(
auction['id']), {'data': {'enquiryPeriod': {'startDate': None}}}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': {u'startDate': [u'This field cannot be deleted']}, u'location': u'body',
u'name': u'enquiryPeriod'}
])

response = self.app.patch_json('/auctions/{}'.format(
auction['id']), {'data': {'tenderPeriod': {'startDate': None}}}, status=422)
self.assertEqual(response.status, '422 Unprocessable Entity')
self.assertEqual(response.content_type, 'application/json')
self.assertEqual(response.json['status'], 'error')
self.assertEqual(response.json['errors'], [
{u'description': {u'startDate': [u'This field cannot be deleted']}, u'location': u'body',
u'name': u'tenderPeriod'}
])

def test_dateModified_auction(self):
response = self.app.get('/auctions')
self.assertEqual(response.status, '200 OK')
Expand Down