Exemple #1
0
 def setUpClass(cls):
     tc1 = TestCase.create(DEFAULT_PROJ,
                           "regression",
                           "regression",
                           caseimportance="high",
                           caselevel="component",
                           caseautomation="notautomated",
                           caseposneg="positive",
                           testtype="functional",
                           subtype1="-")
     cls.NEW_TEST_CASE = tc1.work_item_id
     tc2 = TestCase.create(DEFAULT_PROJ,
                           "regression",
                           "regression",
                           caseimportance="high",
                           caselevel="component",
                           caseautomation="notautomated",
                           caseposneg="positive",
                           testtype="functional",
                           subtype1="-")
     cls.NEW_TEST_CASE2 = tc2.work_item_id
     Plan.create(plan_id=PLAN_ID,
                 plan_name="regression",
                 project_id=DEFAULT_PROJ,
                 parent_id=None,
                 template_id="release")
     cls.NEW_PLAN = PLAN_ID
Exemple #2
0
def test_plan(name, plan_type, parent_name, custom_fields, project):
    """Create a new test plan in Polarion."""
    # Sanitize names to valid values for IDs...
    custom_fields = load_custom_fields(custom_fields)
    plan_id = re.sub(INVALID_CHARS_REGEX, '_', name).replace(' ', '_')
    parent_plan_id = (re.sub(INVALID_CHARS_REGEX, '_', parent_name).replace(
        ' ', '_') if parent_name else parent_name)
    # Check if the test plan already exists
    result = Plan.search('id:{0}'.format(plan_id))
    if len(result) == 1:
        click.echo('Found Test Plan {0}.'.format(name))
        test_plan = result[0]
    else:
        # Unlike Testrun, Pylarion currently does not accept **kwargs in
        # Plan.create() so the custom fields need to be updated after the
        # creation
        test_plan = Plan.create(parent_id=parent_plan_id,
                                plan_id=plan_id,
                                plan_name=name,
                                project_id=project,
                                template_id=plan_type)
        click.echo('Created new Test Plan {0} with ID {1}.'.format(
            name, plan_id))

    update = False
    for field, value in custom_fields.items():
        if getattr(test_plan, field) != value:
            setattr(test_plan, field, value)
            click.echo('Test Plan {0} updated with {1}={2}.'.format(
                test_plan.name, field, value))
            update = True
    if update:
        test_plan.update()
 def test_002_create_plan(self):
     """This test does the following:
     * creates a test riun based on the template created in previous test
     * Verifies that the returned object exists and is not a template
     """
     plan = Plan.create(PLAN_ID, "Regression", DEFAULT_PROJ, None,
                        TEMPLATE_ID)
     self.assertIsNotNone(plan.plan_id)
     self.assertFalse(plan.is_template)
Exemple #4
0
def test_plan(context, name, plan_type, parent_name, project):
    """Create a new test plan in Polarion."""
    # Sanitize names to valid values for IDs...
    plan_id = re.sub(INVALID_CHARS_REGEX, '_', name).replace(' ', '_')
    parent_plan_id = (
        re.sub(INVALID_CHARS_REGEX, '_', parent_name).replace(' ', '_')
        if parent_name else parent_name
    )

    # Check if the test plan already exists
    result = Plan.search('id:{0}'.format(plan_id))
    if len(result) == 1:
        click.echo('Found Test Plan {0}.'.format(name))
        return

    Plan.create(
        parent_id=parent_plan_id,
        plan_id=plan_id,
        plan_name=name,
        project_id=project,
        template_id=plan_type
    )
    click.echo('Created new Test Plan {0} with ID {1}.'.format(name, plan_id))
Exemple #5
0
def create_test_plan(name, plan_type, parent_name, custom_fields, project):
    """Create a new test plan in Polarion.

    :param name: Name for new Test Plan
    :param plan_type: Test Plan type; one of "release" or "iteration"
    :param parent_name: Name of parent Test Plan to link to
    :param custom_fields: Custom fields for the test plan
    :param project: Name of Polarion project
    """

    # Sanitize names to valid values for IDs...
    custom_fields = load_custom_fields(custom_fields)
    plan_id = re.sub(INVALID_CHARS_REGEX, '_', name).replace(' ', '_')
    parent_plan_id = (re.sub(INVALID_CHARS_REGEX, '_', parent_name).replace(
        ' ', '_') if parent_name else parent_name)

    # Check if the test plan already exists
    result = Plan.search(f'id:{plan_id}')
    if result:
        logging.info(f'Found Test Plan {name}.')
        test_plan = result[0]
    else:
        # Unlike Testrun, Pylarion currently does not accept **kwargs in
        # Plan.create() so the custom fields need to be updated after the
        # creation
        test_plan = Plan.create(parent_id=parent_plan_id,
                                plan_id=plan_id,
                                plan_name=name,
                                project_id=project,
                                template_id=plan_type)
        logging.info(f'Created new Test Plan {name} with ID {plan_id}.')

    update = False
    for field, value in custom_fields.items():
        if getattr(test_plan, field) != value:
            setattr(test_plan, field, value)
            logging.info(
                f'Test Plan {test_plan.name} updated with {field}={value}.')
            update = True
    if update:
        test_plan.update()
Exemple #6
0
def test_plan(context, name, plan_type, parent_name, custom_fields, project):
    """Create a new test plan in Polarion."""
    # Sanitize names to valid values for IDs...
    custom_fields = load_custom_fields(custom_fields)
    plan_id = re.sub(INVALID_CHARS_REGEX, '_', name).replace(' ', '_')
    parent_plan_id = (
        re.sub(INVALID_CHARS_REGEX, '_', parent_name).replace(' ', '_')
        if parent_name else parent_name
    )
    # Check if the test plan already exists
    result = Plan.search('id:{0}'.format(plan_id))
    if len(result) == 1:
        click.echo('Found Test Plan {0}.'.format(name))
        test_plan = result[0]
    else:
        # Unlike Testrun, Pylarion currently does not accept **kwargs in
        # Plan.create() so the custom fields need to be updated after the
        # creation
        test_plan = Plan.create(
            parent_id=parent_plan_id,
            plan_id=plan_id,
            plan_name=name,
            project_id=project,
            template_id=plan_type
        )
        click.echo(
            'Created new Test Plan {0} with ID {1}.'.format(name, plan_id))

    update = False
    for field, value in custom_fields.items():
        if getattr(test_plan, field) != value:
            setattr(test_plan, field, value)
            click.echo(
                'Test Plan {0} updated with {1}={2}.'.format(
                    test_plan.name, field, value)
            )
            update = True
    if update:
        test_plan.update()