Ejemplo n.º 1
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()
Ejemplo n.º 2
0
    def print_plan_ids(self, query):
        pls = Plan.search(query,
                          sort='due_date',
                          limit=-1,
                          fields=['due_date', 'name', 'plan_id'])

        ttstr = ('Due Date%-5sPlan ID%-24sPlan Name' % ('', ''))
        lnstr = ('-----------  ---------- %-20s---------' % '')
        print(ttstr)
        print(lnstr)

        for pl in pls:
            print('%-12s %-30s %s' % (pl.due_date, pl.plan_id, pl.name))
Ejemplo n.º 3
0
    def print_plan_ids(self, query):
        pls = Plan.search(query,
                          sort='due_date',
                          limit=-1,
                          fields=['due_date',
                                  'name',
                                  'plan_id'])

        ttstr = ('Due Date%-5sPlan ID%-24sPlan Name' % ('', ''))
        lnstr = ('-----------  ---------- %-20s---------' % '')
        print ttstr
        print lnstr

        for pl in pls:
            print '%-12s %-30s %s' % (pl.due_date, pl.plan_id, pl.name)
Ejemplo n.º 4
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()
Ejemplo n.º 5
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()
Ejemplo n.º 6
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))
 def test_004_search_plan(self):
     lst_res = Plan.search("id:%s" % PLAN_ID)
     self.assertEquals(len(lst_res), 1)
     self.assertEquals(lst_res[0].plan_id, PLAN_ID)
 def test_003_search_template(self):
     lst_res = Plan.search("id:%s" % TEMPLATE_ID, search_templates=True)
     self.assertEquals(len(lst_res), 1)
     self.assertEquals(lst_res[0].plan_id, TEMPLATE_ID)