Exemplo n.º 1
0
def run_simple(tender_file_path):
    with open(tender_file_path) as _file:
        auction_id = json.load(_file).get('data', {}).get('id')
        if auction_id:
            with update_auctionPeriod(tender_file_path, auction_type='simple') as auction_file:
                check_output(TESTS['simple']['worker_cmd'].format(CWD, auction_id, auction_file).split())
    sleep(30)
def main():
    exit_code = 0

    tender_file_path = os.path.join(PWD, "data/tender_data.json")
    run_auction(tender_file_path,
                auction_id="11111111111111111111111111111111")
    sleep(4)
    # with mock_patch('sys.exit') as exit_mock:
    try:
        run_cli([
            '-L',
            'DEBUG',
            '--exitonfailure',
            '-v',
            'tender_file_path:{}'.format(tender_file_path),
            '-v',
            'auction_worker_defaults:{0}/etc/auction_worker_defaults.yaml'.
            format(CWD),
            '-l',
            '{0}/logs/log_simple_auction'.format(CWD),
            '-r',
            '{0}/logs/report_simple_auction'.format(CWD),
            '-d',
            os.path.join(CWD, "logs"),
            PWD,
        ])
    except SystemExit, e:
        exit_code = e.code
Exemplo n.º 3
0
def run_dutch(tender_file_path, auction_id):
    with update_auctionPeriod(tender_file_path,
                              auction_type='dutch') as auction_file:
        check_output(
            '{0}/bin/auction_esco planning {1}'
            ' {0}/etc/auction_worker_dutch.yaml --planning_procerude partial_db --auction_info {2}'
            .format(CWD, auction_id, auction_file).split())
    sleep(30)
def run_multilot(worker_cmd, tender_file_path, auction_id):
    with open(tender_file_path) as _file:
        data = json.load(_file).get('data', {})
        lot_id = data.get('lots', [])[0].get('id')
    with update_auctionPeriod(tender_file_path,
                              auction_type='multilot') as auction_file:
        command_line = worker_cmd.format(CWD, auction_id, auction_file, lot_id)
        check_output(command_line.split())
    sleep(10)
def run_dutch(tender_file_path):
    with open(tender_file_path) as _file:
        auction_id = json.load(_file).get('data').get('id')
    with update_auctionPeriod(tender_file_path,
                              auction_type='dutch') as auction_file:
        check_output(
            '{0}/bin/auction_insider planning {1}'
            ' {0}/etc/auction_worker_insider.yaml --planning_procerude partial_db --auction_info {2}'
            .format(CWD, auction_id, auction_file).split())
    sleep(30)
Exemplo n.º 6
0
def main():
    tender_file_path = os.path.join(PWD, "data/tender_data.json")
    auction_process = run_auction(tender_file_path)
    sleep(4)
    # with mock_patch('sys.exit') as exit_mock:
    exit_code = 0
    try:
        run_cli(['-L', 'DEBUG', '--exitonfailure',
                 '-v', 'tender_file_path:{}'.format(tender_file_path),
                 '-v', 'auction_worker_defaults:{0}/etc/auction_worker_defaults.json'.format(CWD),
                 '-d', os.path.join(CWD, "logs"), PWD,])
    except SystemExit, e:
        exit_code = e.code
def run_auction(tender_file_path, auction_id):
    update_auctionPeriod(tender_file_path)

    with open(tender_file_path) as file:
        data = json.loads(file.read())

    lot_id = data['data']['lots'][0]['id'] if 'lots' in data['data'].keys(
    ) else None
    lot_cli_append = ' --lot {lot_id}'.format(lot_id=lot_id) if lot_id else ''
    command_line = '{0}/bin/auction_worker planning {1} {0}/etc/auction_worker_defaults.yaml --planning_procerude partial_db --auction_info {2}' + lot_cli_append
    check_output(
        command_line.format(CWD, auction_id, tender_file_path).split())
    sleep(30)
def run_texas(tender_file_path):
    with open(tender_file_path) as _file:
        auction_json = json.load(_file).get('data', {})
        auction_id = uuid4().hex
        bids = auction_json.get('bids', [])
        if auction_id:
            check_output(TESTS['texas']['worker_cmd'].format(
                CWD, auction_id).split())

    for bid in bids:
        print 'texas-auctions/{}/login?bidder_id={}&hash={}'.format(
            auction_id, bid["id"], calculate_hash(bid["id"], HASH_SECRET))
    sleep(30)
    return auction_id
def run_esco(worker_cmd, tender_file_path, auction_id):
    with update_auctionPeriod(tender_file_path, auction_type='simple')\
            as auction_file:
        check_output(worker_cmd.format(CWD, auction_id, auction_file).split())
    sleep(10)
Exemplo n.º 10
0
            format(CWD),
            '-l',
            '{0}/logs/log_simple_auction'.format(CWD),
            '-r',
            '{0}/logs/report_simple_auction'.format(CWD),
            '-d',
            os.path.join(CWD, "logs"),
            PWD,
        ])
    except SystemExit, e:
        exit_code = e.code

    tender_file_path = os.path.join(PWD, "data/tender_multilot_data.json")
    run_auction(tender_file_path,
                auction_id="22222222222222222222222222222222")
    sleep(4)
    # with mock_patch('sys.exit') as exit_mock:
    try:
        run_cli([
            '-L',
            'DEBUG',
            '--exitonfailure',
            '-v',
            'tender_file_path:{}'.format(tender_file_path),
            '-v',
            'auction_worker_defaults:{0}/etc/auction_worker_defaults.yaml'.
            format(CWD),
            '-l',
            '{0}/logs/log_multilot_auction'.format(CWD),
            '-r',
            '{0}/logs/report_multilot_auction'.format(CWD),
Exemplo n.º 11
0
def main():
    TESTS = {}
    for entry_point in iter_entry_points('openprocurement.auction.robottests'):
        suite = entry_point.load()
        TESTS.update(suite())

    parser = argparse.ArgumentParser('Auction test runner')
    parser.add_argument('suite',
                        choices=TESTS.keys(),
                        default='simple',
                        nargs='?',
                        help='test_suite')

    parser.add_argument('--browser',
                        dest='browser',
                        choices=['firefox', 'chrome', 'phantomjs'],
                        default='chrome',
                        nargs='?',
                        help='supported browsers')

    parser.add_argument('--ip',
                        dest='ip',
                        nargs='?',
                        help='ip of the remote server where tests will be run')

    parser.add_argument('--port',
                        dest='port',
                        nargs='?',
                        help='port of the remote server where tests will be '
                             'run')

    args = parser.parse_args()

    if args.port and (not args.ip):
        parser.error('The --port argument requires the --ip')

    if args.ip and (args.browser != 'chrome'):
        parser.error('Only chrome is allowed for remote test running')

    port = getattr(args, 'port', '4444')
    remote_url = 'None' if not args.ip else 'http://{}:{}/wd/hub'\
        .format(args.ip, port)

    desired_capabilities = DesiredCapabilities.CHROME if \
        args.browser == 'chrome' else 'None'

    test = TESTS[args.suite]

    test['runner'](test['worker_cmd'], test['tender_file_path'],
                   test['auction_id'])

    auction_worker_defaults = test['auction_worker_defaults']
    cli_args = [
        '-L',
        'TRACE',
        '--exitonfailure',
        '-v', 'tender_file_path:{}'.format(test['tender_file_path']),
        '-v', auction_worker_defaults.format(CWD),
        '-v', 'auction_id:{}'.format(test['auction_id']),
        '-v', 'BROWSER:{}'.format(args.browser),
        '-v', 'remote_url:{}'.format(remote_url),
        '-v', 'desired_capabilities:{}'.format(desired_capabilities),
        '-l', '{0}/logs/log_{1}'.format(CWD, args.suite),
        '-r', '{0}/logs/report_{1}'.format(CWD, args.suite),
        '-P', test['suite'],
        '-d', os.path.join(CWD, "logs"),
        test['suite']
    ]
    sleep(4)
    try:
        run_cli(cli_args)
    except SystemExit, e:
        exit_code = e.code