<commit_before>__author__ = 'thauser'

import pytest
import time
from test import testutils
from pnc_cli import buildconfigurations
from pnc_cli import buildconfigurationsets
from pnc_cli import bpmbuildconfigurations
from pnc_cli import products
from pnc_cli import productversions
from pnc_cli import productmilestones
from pnc_cli import productreleases
from pnc_cli import projects


@pytest.fixture(scope='module')
def new_product():
    randname = testutils.gen_random_name()
    product = products.create_product(randname + "-product",
                                      randname,
                                      description="PNC CLI: test product")
    return product


@pytest.fixture(scope='module')
def new_project(request):
    project = projects.create_project(name=testutils.gen_random_name() + '-project',
                                      description="PNC CLI: test project")

    def teardown():
        projects.delete_project(id=project.id)

    request.addfinalizer(teardown)
    return project


@pytest.fixture(scope='function')
def new_set(request):
    set = buildconfigurationsets.create_build_configuration_set(name=testutils.gen_random_name() + "-set",
                                                                product_version_id=1)

    def teardown():
        buildconfigurationsets.delete_build_configuration_set(id=set.id)

    request.addfinalizer(teardown)
    return set

#helper function for checking BC creation
def contains_event_type(events, types):
    for event in events:
        if (event.event_type in types):
            return True

    return False

@pytest.fixture(scope='function')
#def new_config(request, new_project, new_environment):
def new_config(request, new_project):
    bc_name = testutils.gen_random_name() + '-config'
    created_bc = buildconfigurations.create_build_configuration(
        name=bc_name,
        project=new_project.id,
        environment=1,
        build_script='mvn javadoc:jar deploy',
        product_version_id=1,
        scm_repo_url='git+ssh://pnc-gerrit-stage@code-stage.eng.nay.redhat.com:29418/productization/git.app.eng.bos.redhat.com/liquibase.git',
        scm_revision='branch-liquibase-parent-3.4.1')

    def teardown():
        buildconfigurations.delete_build_configuration(id=created_bc.id)

    request.addfinalizer(teardown)
    return created_bc


@pytest.fixture(scope='module')
def new_version(new_product):
    version = productversions.create_product_version(
        product_id=new_product.id,
        version=get_unique_version(new_product.id))
    return version


def get_unique_version(product_id):
    rand_version = testutils.gen_random_version()
    existing = products.list_versions_for_product(id=product_id, page_size=100000)
    while existing is not None and rand_version in [x.version for x in existing]:<commit_msg>test update<commit_after>__author__ = 'thauser'

import pytest
import time
from test import testutils
from pnc_cli import buildconfigurations
from pnc_cli import buildconfigurationsets
from pnc_cli import bpmbuildconfigurations
from pnc_cli import products
from pnc_cli import productversions
from pnc_cli import productmilestones
from pnc_cli import productreleases
from pnc_cli import projects


@pytest.fixture(scope='module')
def new_product():
    randname = testutils.gen_random_name()
    product = products.create_product(randname + "-product",
                                      randname,
                                      description="PNC CLI: test product")
    return product


@pytest.fixture(scope='module')
def new_project(request):
    project = projects.create_project(name=testutils.gen_random_name() + '-project',
                                      description="PNC CLI: test project")

    def teardown():
        projects.delete_project(id=project.id)

    request.addfinalizer(teardown)
    return project


@pytest.fixture(scope='function')
def new_set(request):
    set = buildconfigurationsets.create_build_configuration_set(name=testutils.gen_random_name() + "-set",
                                                                product_version_id=1)

    def teardown():
        buildconfigurationsets.delete_build_configuration_set(id=set.id)

    request.addfinalizer(teardown)
    return set

#helper function for checking BC creation
def contains_event_type(events, types):
    for event in events:
        if (event.event_type in types):
            return True

    return False

@pytest.fixture(scope='function')
#def new_config(request, new_project, new_environment):
def new_config(request, new_project):
    bc_name = testutils.gen_random_name() + '-config'
    created_bc = buildconfigurations.create_build_configuration(
        name=bc_name,
        project=new_project.id,
        environment=2,
        build_script='mvn javadoc:jar deploy',
        product_version_id=1,
        scm_repo_url='git+ssh://<EMAIL>:29418/productization/git.app.eng.bos.redhat.com/liquibase.git',
        scm_revision='branch-liquibase-parent-3.4.1')

    def teardown():
        buildconfigurations.delete_build_configuration(id=created_bc.id)

    request.addfinalizer(teardown)
    return created_bc


@pytest.fixture(scope='module')
def new_version(new_product):
    version = productversions.create_product_version(
        product_id=new_product.id,
        version=get_unique_version(new_product.id))
    return version


def get_unique_version(product_id):
    rand_version = testutils.gen_random_version()
    existing = products.list_versions_for_product(id=product_id, page_size=100000)
    while existing is not None and rand_version in [x.version for x in existing]:
{'fraction_non_alphanumeric': 0.08508384819064431, 'fraction_numerical': 0.006001765225066196, 'mean_word_length': 3.443921568627451, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4124539', 'n_tokens_mistral': 1693, 'n_tokens_neox': 1637, 'n_words': 328}