-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
220 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
openprocurement/auctions/geb/managers/changers/actions/utils.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from openprocurement.auctions.geb.managers.changers.base import ( | ||
BaseAction | ||
) | ||
|
||
|
||
class SetAuctionPeriodStartDateAction(BaseAction): | ||
""" | ||
Action that will be triggered when chronograph or bridge | ||
come to patch auction period | ||
""" | ||
validators = [] | ||
|
||
@classmethod | ||
def demand(cls, request, context): | ||
""" | ||
Check if request patch auctionPeriod.startDate | ||
""" | ||
auction_period = request.validated['json_data'].get('auctionPeriod') | ||
if auction_period and auction_period.get('startDate'): | ||
return cls | ||
return False | ||
|
||
def act(self): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
openprocurement/auctions/geb/tests/blanks/auction_period_patch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from iso8601 import parse_date | ||
from datetime import timedelta | ||
|
||
|
||
def set_auctionPeriod_startDate_rectification(test_case): | ||
response = test_case.app.get(test_case.ENTRYPOINTS['auction']) | ||
auction = response.json['data'] | ||
should_start_after = auction['auctionPeriod']['shouldStartAfter'] | ||
start_date = parse_date(should_start_after) + timedelta(days=1) | ||
auction_period = {'auctionPeriod': {'startDate': start_date.isoformat()}} | ||
|
||
request_data = {"data": auction_period} | ||
test_case.app.patch_json(test_case.ENTRYPOINTS['auction'], request_data) | ||
|
||
response = test_case.app.get(test_case.ENTRYPOINTS['auction']) | ||
auction = response.json['data'] | ||
test_case.assertEqual(start_date, parse_date(auction['auctionPeriod']['startDate'])) | ||
|
||
|
||
def set_auctionPeriod_startDate_tendering(test_case): | ||
context = test_case.procedure.snapshot() | ||
auction = context['auction'] | ||
|
||
entrypoint = '/auctions/{}'.format(auction['data']['id']) | ||
|
||
response = test_case.app.get(entrypoint) | ||
auction = response.json['data'] | ||
|
||
should_start_after = auction['auctionPeriod']['shouldStartAfter'] | ||
start_date = parse_date(should_start_after) + timedelta(days=1) | ||
auction_period = {'auctionPeriod': {'startDate': start_date.isoformat()}} | ||
|
||
request_data = {"data": auction_period} | ||
test_case.app.patch_json(entrypoint, request_data) | ||
|
||
response = test_case.app.get(entrypoint) | ||
auction = response.json['data'] | ||
test_case.assertEqual(start_date, parse_date(auction['auctionPeriod']['startDate'])) | ||
|
||
|
||
def set_auctionPeriod_startDate_enquiring(test_case): | ||
context = test_case.procedure.snapshot() | ||
auction = context['auction'] | ||
|
||
entrypoint = '/auctions/{}'.format(auction['data']['id']) | ||
|
||
response = test_case.app.get(entrypoint) | ||
auction = response.json['data'] | ||
|
||
should_start_after = auction['auctionPeriod']['shouldStartAfter'] | ||
start_date = parse_date(should_start_after) + timedelta(days=1) | ||
auction_period = {'auctionPeriod': {'startDate': start_date.isoformat()}} | ||
|
||
request_data = {"data": auction_period} | ||
test_case.app.patch_json(entrypoint, request_data) | ||
|
||
response = test_case.app.get(entrypoint) | ||
auction = response.json['data'] | ||
test_case.assertEqual(start_date, parse_date(auction['auctionPeriod']['startDate'])) |
73 changes: 73 additions & 0 deletions
73
openprocurement/auctions/geb/tests/cases/auction_bridge.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# -*- coding: utf-8 -*- | ||
import unittest | ||
|
||
from openprocurement.auctions.core.tests.base import snitch | ||
from openprocurement.auctions.geb.tests.base import ( | ||
BaseWebTest, | ||
) | ||
|
||
from openprocurement.auctions.geb.tests.states import ( | ||
ProcedureMachine | ||
) | ||
from openprocurement.auctions.geb.tests.blanks.auction_period_patch import ( | ||
set_auctionPeriod_startDate_enquiring, | ||
set_auctionPeriod_startDate_rectification, | ||
set_auctionPeriod_startDate_tendering | ||
) | ||
|
||
|
||
class AuctionBridgeTenderingTest(BaseWebTest): | ||
test_set_auctionPeriod_startDate_tendering = snitch(set_auctionPeriod_startDate_tendering) | ||
|
||
def setUp(self): | ||
super(AuctionBridgeTenderingTest, self).setUp() | ||
|
||
procedure = ProcedureMachine() | ||
procedure.set_db_connector(self.db) | ||
procedure.toggle('active.tendering') | ||
|
||
self.procedure = procedure | ||
self.app.authorization = ('Basic', ('auction', '')) | ||
|
||
|
||
class AuctionBridgeRectificationTest(BaseWebTest): | ||
test_set_auctionPeriod_startDate_rectification = snitch(set_auctionPeriod_startDate_rectification) | ||
|
||
def setUp(self): | ||
super(AuctionBridgeRectificationTest, self).setUp() | ||
|
||
procedure = ProcedureMachine() | ||
procedure.set_db_connector(self.db) | ||
procedure.toggle('active.rectification') | ||
context = procedure.snapshot() | ||
|
||
self.auction = context['auction'] | ||
|
||
entrypoints = {} | ||
entrypoints['auction'] = '/auctions/{}'.format(self.auction['data']['id']) | ||
self.ENTRYPOINTS = entrypoints | ||
|
||
self.app.authorization = ('Basic', ('auction', '')) | ||
|
||
|
||
class AuctionBridgeEnquiryTest(BaseWebTest): | ||
|
||
test_set_auctionPeriod_startDate_enquiring = snitch(set_auctionPeriod_startDate_enquiring) | ||
|
||
def setUp(self): | ||
super(AuctionBridgeEnquiryTest, self).setUp() | ||
|
||
procedure = ProcedureMachine() | ||
procedure.set_db_connector(self.db) | ||
procedure.toggle('active.enquiry') | ||
|
||
self.procedure = procedure | ||
self.app.authorization = ('Basic', ('auction', '')) | ||
|
||
|
||
def suite(): | ||
suite = unittest.TestSuite() | ||
# auction tests | ||
suite.addTest(unittest.makeSuite(AuctionBridgeTenderingTest)) | ||
suite.addTest(unittest.makeSuite(AuctionBridgeEnquiryTest)) | ||
suite.addTest(unittest.makeSuite(AuctionBridgeRectificationTest)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters