def module_auction_switch_to_qualification_outstanding(test_case):
    context = test_case.procedure.snapshot(fixture=AUCTION_WITH_URLS)
    auction = context['auction']
    bids = context['bids']
    auction_url = '/auctions/{}/auction'.format(auction['data']['id'])

    # create module auction results
    bid_value = {"value": {"currency": "UAH", "valueAddedTaxIncluded": True}}
    loser = deepcopy(bid_value)
    loser['id'] = bids[0]['data']['id']
    loser['value']['amount'] = auction['data']['value']['amount']

    winner = deepcopy(bid_value)
    winner['id'] = bids[1]['data']['id']
    winner['value']['amount'] = auction['data']['value']['amount'] + auction[
        'data']['minimalStep']['amount']

    request_data = {'bids': [loser, winner]}

    # get auctionPeriod.startDate
    entrypoint = '/auctions/{}'.format(auction['data']['id'])
    response = test_case.app.get(entrypoint)
    data = response.json['data']
    auction_start_date = parse_date(data['auctionPeriod']['startDate'])

    # simulate invalid auction time
    # set 'now' to 19:00 next day of auctionPeriod.startDate
    outstanding_auction_time = set_specific_hour(
        auction_start_date + timedelta(days=1), 19)
    with freeze_time(outstanding_auction_time):
        response = test_case.app.post_json(auction_url, {'data': request_data})

    response = test_case.app.get('/auctions/{}/awards'.format(
        auction['data']['id']))
    awards = response.json['data']
    award = awards[0]

    # check generated verificationPeriod
    verification_start_date = parse_date(
        award['verificationPeriod']['startDate'])
    verification_end_date = parse_date(award['verificationPeriod']['endDate'])
    expected_start_date = set_specific_hour(verification_end_date, 17)
    test_case.assertEqual(verification_start_date, expected_start_date)

    # check generated signing
    signing_end_date = parse_date(award['signingPeriod']['endDate'])
    signing_start_date = parse_date(award['signingPeriod']['startDate'])
    expected_start_date = set_specific_hour(signing_end_date, 17)
    test_case.assertEqual(signing_start_date, expected_start_date)
예제 #2
0
    def signingPeriod(self):
        start_awarding = get_now()
        auction_end_date = self.context.auctionPeriod.endDate
        verification_end_date = self.verification_period['endDate']

        # set endDate
        end_date = cbd(verification_end_date,
                       timedelta(days=0),
                       self.context,
                       specific_hour=23) + timedelta(minutes=59)

        # set startDate
        start_date = start_awarding

        if auction_end_date:

            # find the outstanding time for bringing result of module auction
            outstanding_auction_time = set_specific_hour(auction_end_date, 18)

            # check if module auction outstanding time to brings result
            if start_awarding > outstanding_auction_time:
                start_date = cbd(start_awarding,
                                 timedelta(days=0),
                                 self.context,
                                 specific_hour=17)

        singing_period = {'startDate': start_date, 'endDate': end_date}

        return singing_period
예제 #3
0
    def verificationPeriod(self):
        start_awarding = get_now()
        auction_end_date = self.context.auctionPeriod.endDate

        start_date = start_awarding

        if auction_end_date:
            end_date = cbd(start_awarding,
                           timedelta(days=0),
                           self.context,
                           specific_hour=18)

            # find the outstanding time for bringing result of module auction
            outstanding_auction_time = set_specific_hour(auction_end_date, 18)

            # check if module auction outstanding time to brings result
            if start_awarding > outstanding_auction_time:
                start_date = cbd(start_awarding,
                                 timedelta(days=0),
                                 self.context,
                                 specific_hour=17)
        else:
            # if auction minNumberOfQualifiedBids was 1
            # only 1 bid was in status 'active'
            # after 'active.enquiry' auction switch to 'active.qualification'
            # verificationPeriod start after end of enquiryPeriod
            end_date = cbd(start_awarding,
                           timedelta(days=1),
                           self.context,
                           specific_hour=18,
                           working_days=True)

        verification_period = {'startDate': start_date, 'endDate': end_date}
        self.verification_period = verification_period
        return verification_period
def module_auction_post_result_invalid_number_of_bids(test_case):
    expected_http_status = '422 Unprocessable Entity'
    context = test_case.procedure.snapshot(fixture=AUCTION_WITH_URLS)
    auction = context['auction']
    bids = context['bids']
    auction_url = '/auctions/{}/auction'.format(auction['data']['id'])

    request_data = {
        'bids': [{
            "id": bids[0]['data']['id'],
            "value": {
                "amount": auction['data']['value']['amount'],
                "currency": "UAH",
                "valueAddedTaxIncluded": True
            }
        }]
    }

    # get auctionPeriod.startDate
    entrypoint = '/auctions/{}'.format(auction['data']['id'])
    response = test_case.app.get(entrypoint)
    data = response.json['data']
    auction_start_date = parse_date(data['auctionPeriod']['startDate'])

    # simulate valid auction time
    # set 'now' to 14:00 day of auctionPeriod.startDate
    valid_auction_time = set_specific_hour(auction_start_date, 14)
    with freeze_time(valid_auction_time):
        response = test_case.app.post_json(auction_url, {'data': request_data},
                                           status=422)
    test_case.assertEqual(response.status, expected_http_status)
def calc_expected_auction_end_time(auction_start_date):
    # calculate expected auction end time
    # it is need for checking replaning of module auction
    # if now time is more then this value and auctionPeriod.endDate is None
    # auction will be replaning
    end_time = set_specific_hour(auction_start_date, 18)
    return end_time
def module_auction_switch_to_unsuccessful(test_case):
    expected_http_status = '200 OK'
    context = test_case.procedure.snapshot(fixture=AUCTION_WITH_URLS)
    auction = context['auction']
    bids = context['bids']
    auction_url = '/auctions/{}/auction'.format(auction['data']['id'])

    request_data = {
        'bids': [{
            "id": bids[0]['data']['id'],
            "value": {
                "amount": auction['data']['value']['amount'],
                "currency": "UAH",
                "valueAddedTaxIncluded": True
            }
        }, {
            "id": bids[1]['data']['id'],
            "value": {
                "amount": auction['data']['value']['amount'],
                "currency": "UAH",
                "valueAddedTaxIncluded": True
            }
        }]
    }

    # get auctionPeriod.startDate
    entrypoint = '/auctions/{}'.format(auction['data']['id'])
    response = test_case.app.get(entrypoint)
    data = response.json['data']
    auction_start_date = parse_date(data['auctionPeriod']['startDate'])

    # simulate valid auction time
    # set 'now' to 14:00 next day of auctionPeriod.startDate
    valid_auction_time = set_specific_hour(
        auction_start_date + timedelta(days=1), 14)
    with freeze_time(valid_auction_time):
        response = test_case.app.post_json(auction_url, {'data': request_data})
    test_case.assertEqual(response.status, expected_http_status)

    entrypoint = '/auctions/{}'.format(auction['data']['id'])
    response = test_case.app.get(entrypoint)
    test_case.assertEqual(response.json['data']['status'], 'unsuccessful')
def replaning_auction(test_case):

    # get auctionPeriod.startDate
    response = test_case.app.get(test_case.ENTRYPOINTS['auction_get'])
    auction = response.json['data']
    auction_start_date = parse_date(auction['auctionPeriod']['startDate'])

    # simulate outstanding auction time
    # set 'now' to 19:00 day of auctionPeriod.startDate
    outstanding_auction_time = set_specific_hour(auction_start_date, 19)
    with freeze_time(outstanding_auction_time):
        request_data = {'data': {'id': test_case.auction['data']['id']}}
        response = test_case.app.patch_json(test_case.ENTRYPOINTS['auction_patch'], request_data)
    auction = response.json['data']
    should_start_after = parse_date(auction['auctionPeriod']['shouldStartAfter'])
    auction_start_date = parse_date(auction['auctionPeriod']['startDate'])

    # check new shouldStartAfter
    should_start_after = parse_date(auction['auctionPeriod']['shouldStartAfter'])
    test_case.assertLess(auction_start_date, should_start_after)
def module_auction_switch_to_qualification(test_case):
    context = test_case.procedure.snapshot(fixture=AUCTION_WITH_URLS)
    auction = context['auction']
    bids = context['bids']
    auction_url = '/auctions/{}/auction'.format(auction['data']['id'])

    # create module auction results
    bid_value = {"value": {"currency": "UAH", "valueAddedTaxIncluded": True}}
    loser = deepcopy(bid_value)
    loser['id'] = bids[0]['data']['id']
    loser['value']['amount'] = auction['data']['value']['amount']

    winner = deepcopy(bid_value)
    winner['id'] = bids[1]['data']['id']
    winner['value']['amount'] = auction['data']['value']['amount'] + auction[
        'data']['minimalStep']['amount']

    request_data = {'bids': [loser, winner]}

    # get auctionPeriod.startDate
    entrypoint = '/auctions/{}'.format(auction['data']['id'])
    response = test_case.app.get(entrypoint)
    data = response.json['data']
    auction_start_date = parse_date(data['auctionPeriod']['startDate'])

    # simulate valid auction time
    # set 'now' to 14:00 next day of auctionPeriod.startDate
    valid_auction_time = set_specific_hour(
        auction_start_date + timedelta(days=1), 14)
    with freeze_time(valid_auction_time):
        response = test_case.app.post_json(auction_url, {'data': request_data})
    expected_http_status = '200 OK'
    test_case.assertEqual(response.status, expected_http_status)

    # check generated auction status
    entrypoint = '/auctions/{}'.format(auction['data']['id'])
    response = test_case.app.get(entrypoint)
    test_case.assertEqual(response.json['data']['status'],
                          'active.qualification')

    # check generated award
    response = test_case.app.get('/auctions/{}/awards'.format(
        auction['data']['id']))
    awards = response.json['data']
    test_case.assertEqual(len(awards), 1)

    award = awards[0]
    test_case.assertIsNotNone(award.get('verificationPeriod'))
    test_case.assertIsNotNone(award.get('signingPeriod'))
    test_case.assertEqual(award['bid_id'], winner['id'])
    test_case.assertEqual(award['status'], 'pending')

    # check generated verificationPeriod
    entrypoint = '/auctions/{}'.format(auction['data']['id'])
    response = test_case.app.get(entrypoint)
    auction = response.json['data']
    auction_period_end_date = parse_date(auction['auctionPeriod']['endDate'])
    verification_start_date = parse_date(
        award['verificationPeriod']['startDate'])
    verification_end_date = parse_date(award['verificationPeriod']['endDate'])

    expected_end_date = set_specific_hour(auction_period_end_date, 18)
    test_case.assertEqual(verification_end_date, expected_end_date)

    # check generated signing
    signing_end_date = parse_date(award['signingPeriod']['endDate'])
    signing_start_date = parse_date(award['signingPeriod']['startDate'])

    expected_end_date = ccbd(verification_end_date,
                             timedelta(days=0),
                             specific_hour=23) + timedelta(minutes=59)
    test_case.assertEqual(signing_end_date, expected_end_date)
    test_case.assertEqual(signing_start_date, verification_start_date)

    # check generated awardPeriod
    auction = response.json['data']
    award_period_start = parse_date(auction['awardPeriod']['startDate'])
    test_case.assertEqual(award_period_start, verification_start_date)
auction = deepcopy(AUCTION)
auction['bids'] = [BID_DRAFT_WITH_DOCUMENT]
AUCTION_WITH_BID_DRAFT_WITH_DOCUMENT = auction

# auction with bid in 'pending' with document
auction = deepcopy(AUCTION)
auction['bids'] = [BID_PENDING_FIRST_WITH_DOCUMENT]
AUCTION_WITH_BID_PENDING_WITH_DOCUMENT = auction

# auction with bid in 'active' with document
auction = deepcopy(AUCTION)
auction['bids'] = [BID_ACTIVE_FIRST_WITH_DOCUMENT]
AUCTION_WITH_BID_ACTIVE_WITH_DOCUMENT = auction

# auction in end 'active.enquiry' with two bid in status 'active'
enquiry_end = set_specific_hour(get_now(), 20)
calculator = Calculator(enquiry_end, 'enquiryPeriod', 'end')
auction = deepcopy(AUCTION)
auction['status'] = 'active.enquiry'
auction["rectificationPeriod"] = {
    "startDate": calculator.rectificationPeriod.startDate.isoformat(),
    "endDate": calculator.rectificationPeriod.endDate.isoformat()
}
auction["tenderPeriod"] = {
    "startDate": calculator.tenderPeriod.startDate.isoformat(),
    "endDate": calculator.tenderPeriod.endDate.isoformat()
}
auction["enquiryPeriod"] = {
    "startDate": calculator.enquiryPeriod.startDate.isoformat(),
    "endDate": calculator.enquiryPeriod.endDate.isoformat()
}
예제 #10
0
from copy import deepcopy

from openprocurement.auctions.core.utils import (set_specific_hour)
from openprocurement.auctions.geb.tests.fixtures.active_enquiry import (
    AUCTION as ACTIVE_ENQUIRY_AUCTION)

from openprocurement.auctions.geb.tests.fixtures.cancellations import (
    CANCELLATION, CANCELLATION_WITH_DOCUMENTS)
from openprocurement.auctions.geb.tests.fixtures.bids import (BID_ACTIVE_FIRST)
from openprocurement.auctions.geb.tests.fixtures.documents import (DOCUMENT)
from openprocurement.auctions.geb.tests.fixtures.questions import (QUESTION)
from openprocurement.auctions.core.utils import get_now
from openprocurement.auctions.geb.tests.fixtures.calculator import (Calculator)

# 'active.auction' start yesterday in 20:00
auction_period_start_date = set_specific_hour(get_now() - timedelta(days=1),
                                              20)

calculator = Calculator(auction_period_start_date, 'auctionPeriod', 'start')
auction = deepcopy(ACTIVE_ENQUIRY_AUCTION)
auction['status'] = 'active.auction'
auction["rectificationPeriod"] = {
    "startDate": calculator.rectificationPeriod.startDate.isoformat(),
    "endDate": calculator.rectificationPeriod.endDate.isoformat()
}
auction["tenderPeriod"] = {
    "startDate": calculator.tenderPeriod.startDate.isoformat(),
    "endDate": calculator.tenderPeriod.endDate.isoformat()
}
auction["enquiryPeriod"] = {
    "startDate": calculator.enquiryPeriod.startDate.isoformat(),
    "endDate": calculator.enquiryPeriod.endDate.isoformat()