<commit_before>import httplib
import logging
import os
import re
import shutil
import tempfile
import time
from urlparse import urlparse

import pytest
from git import Repo

from pnc_cli import utils
from pnc_cli.swagger_client.apis.buildconfigurations_api import BuildconfigurationsApi
from pnc_cli.swagger_client.apis.runningbuildrecords_api import RunningbuildrecordsApi
from pnc_cli.swagger_client.apis.buildconfigurationsets_api import BuildconfigurationsetsApi
from pnc_cli.swagger_client.apis.buildrecords_api import BuildrecordsApi
from test.integration.conftest import new_config

# setup logging to print timestamps
logging.basicConfig(format='[%(asctime)s %(levelname)s] %(message)s')
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

POM_VERSION_UPDATE_REGEX_STR = r'^-\s*<version>([\w\.-]+)</version>\s*^\+\s*<version>(\d[\w\.-]*redhat-\d+)</version>'
POM_VERSION_UPDATE_REGEX = re.compile(POM_VERSION_UPDATE_REGEX_STR, re.MULTILINE)

BUILD_STATUS_DONE = 'DONE'


@pytest.fixture(scope='function', autouse=True)
def get_running_api():
    global running_api
    running_api = RunningbuildrecordsApi(utils.get_api_client())


@pytest.fixture(scope='function', autouse=True)
def get_configs_api():
    global configs_api
    configs_api = BuildconfigurationsApi(utils.get_api_client())


@pytest.fixture(scope='function', autouse=True)
def get_sets_api():
    global sets_api
    sets_api = BuildconfigurationsetsApi(utils.get_api_client())


@pytest.fixture(scope='function', autouse=True)
def get_records_api():
    global records_api
    records_api = BuildrecordsApi(utils.get_api_client())


def test_run_single_build(new_config):
    """ Run a single build configuration defined by the 'new_config' method
    and verify the build output """
    assert (new_config is not None, 'Unable to create build configuration')

    triggered_build = configs_api.trigger(id=new_config.id).content
    assert (triggered_build is not None, 'Unable to start build')

    logger.info("Build %s is running...", triggered_build.id)
    while True:
        if not running_api.get_all_for_bc(id=new_config.id).content:
            break
        time.sleep(5)
    logger.info("Build %s is done!", triggered_build.id)

    build_record = records_api.get_specific(triggered_build.id).content
    build_record_checks(build_record)


@pytest.mark.skip(reason="PNC doesn't complete builds in a reasonable time")
def test_run_group_build(request, new_set, new_environment, new_project):
    assert (new_set is not None, 'Unable to create Build Configuration Group')

    config_one = new_config(request, new_environment, new_project)
    config_two = new_config(request, new_environment, new_project)
    config_three = new_config(request, new_environment, new_project)
    sets_api.add_configuration(id=new_set.id, body=config_one)
    sets_api.add_configuration(id=new_set.id, body=config_two)
    sets_api.add_configuration(id=new_set.id, body=config_three)

    # this returns a list of build_records, one for each build configuration in the set
    triggered_build = sets_api.build(id=new_set.id).content
    assert (triggered_build is not None, 'Unable to start build')

    triggered_build_ids = [x.id for x in triggered_build]
    for id in triggered_build_ids:
        logger.info("Group Build: Build %s is running...", id)

    while True:
        if not running_api.get_all_for_bc_set(id=new_set.id).content:
            break
        time.sleep(5)
    for id in triggered_build_ids:
        logger.info("Build group %s is done!", id)

    for id in triggered_build_ids:<commit_msg>fix mismatch of parameters<commit_after>import httplib
import logging
import os
import re
import shutil
import tempfile
import time
from urlparse import urlparse

import pytest
from git import Repo

from pnc_cli import utils
from pnc_cli.swagger_client.apis.buildconfigurations_api import BuildconfigurationsApi
from pnc_cli.swagger_client.apis.runningbuildrecords_api import RunningbuildrecordsApi
from pnc_cli.swagger_client.apis.buildconfigurationsets_api import BuildconfigurationsetsApi
from pnc_cli.swagger_client.apis.buildrecords_api import BuildrecordsApi
from test.integration.conftest import new_config

# setup logging to print timestamps
logging.basicConfig(format='[%(asctime)s %(levelname)s] %(message)s')
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)

POM_VERSION_UPDATE_REGEX_STR = r'^-\s*<version>([\w\.-]+)</version>\s*^\+\s*<version>(\d[\w\.-]*redhat-\d+)</version>'
POM_VERSION_UPDATE_REGEX = re.compile(POM_VERSION_UPDATE_REGEX_STR, re.MULTILINE)

BUILD_STATUS_DONE = 'DONE'


@pytest.fixture(scope='function', autouse=True)
def get_running_api():
    global running_api
    running_api = RunningbuildrecordsApi(utils.get_api_client())


@pytest.fixture(scope='function', autouse=True)
def get_configs_api():
    global configs_api
    configs_api = BuildconfigurationsApi(utils.get_api_client())


@pytest.fixture(scope='function', autouse=True)
def get_sets_api():
    global sets_api
    sets_api = BuildconfigurationsetsApi(utils.get_api_client())


@pytest.fixture(scope='function', autouse=True)
def get_records_api():
    global records_api
    records_api = BuildrecordsApi(utils.get_api_client())


def test_run_single_build(new_config):
    """ Run a single build configuration defined by the 'new_config' method
    and verify the build output """
    assert (new_config is not None, 'Unable to create build configuration')

    triggered_build = configs_api.trigger(id=new_config.id).content
    assert (triggered_build is not None, 'Unable to start build')

    logger.info("Build %s is running...", triggered_build.id)
    while True:
        if not running_api.get_all_for_bc(id=new_config.id).content:
            break
        time.sleep(5)
    logger.info("Build %s is done!", triggered_build.id)

    build_record = records_api.get_specific(triggered_build.id).content
    build_record_checks(build_record)


def test_run_group_build(request, new_set, new_environment, new_project):
    assert (new_set is not None, 'Unable to create Build Configuration Group')
    assert (new_environment is not None, 'Unable to create Build Environment')
    config_one = new_config(request, new_project, new_environment)
    config_two = new_config(request, new_project, new_environment)
    config_three = new_config(request, new_project, new_environment)
    sets_api.add_configuration(id=new_set.id, body=config_one)
    sets_api.add_configuration(id=new_set.id, body=config_two)
    sets_api.add_configuration(id=new_set.id, body=config_three)

    # this returns a list of build_records, one for each build configuration in the set
    triggered_build = sets_api.build(id=new_set.id).content
    assert (triggered_build is not None, 'Unable to start build')

    triggered_build_ids = [x.id for x in triggered_build]
    for id in triggered_build_ids:
        logger.info("Group Build: Build %s is running...", id)

    while True:
        if not running_api.get_all_for_bc_set(id=new_set.id).content:
            break
        time.sleep(5)
    for id in triggered_build_ids:
        logger.info("Build group %s is done!", id)

    for id in triggered_build_ids:
{'fraction_non_alphanumeric': 0.09473684210526316, 'fraction_numerical': 0.000554016620498615, 'mean_word_length': 5.062972292191436, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '660432', 'n_tokens_mistral': 2297, 'n_tokens_neox': 2284, 'n_words': 526}