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
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_009_update(self): plan = Plan(project_id=DEFAULT_PROJ, plan_id=PLAN_ID) plan.color = "red" plan.update() plan.color = "" plan.reload() self.assertEquals(plan.color, "red")
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)
def test_001_create_template(self): """This test does the following: * Creates a Plan template with no parent * Verifies that the returned object exists and is a template The parent attribute is not returned """ template = Plan.create_plan_template(TEMPLATE_ID, "Regression", DEFAULT_PROJ, None) self.assertIsNotNone(template.plan_id) self.assertTrue(template.is_template)
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()
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()
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))
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 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)
def test_010_delete(self): Plan.delete_plans(DEFAULT_PROJ, PLAN_ID) with self.assertRaises(PylarionLibException): Plan(project_id=DEFAULT_PROJ, 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)
def create_requirements(bz_rfes, bz_connection): idx = 0 plan = Plan(project_id=POLARION_PRODUCT, plan_id=POLARION_VERSION) req_ids = list() # bz_rfe = bz_rfes[0] #for x in range(103,127): for bz_rfe in bz_rfes: #bz_rfe = bz_rfes[x] bug_title, named_parms, bug_description, bug_link, bug_id, bug_priority, bug_severity, bug_dfg = get_bug_params( bz_rfe) print "\n%s - start bug %s" % (datetime.datetime.now(), idx), idx += 1 print '"{}"'.format(bug_link) if isRequirementInPolarion(bug_link) == False: #TODO Convert bugzilla to Polarion priority and set #named_parms["priority"] = convert_polarion_priority(bug_priority) # Convert bugzilla to Polarion severity and set named_parms["severity"] = convert_polarion_severity(bug_severity) # Set Polarion requirement type named_parms["reqtype"] = "functional" #Cenvert DFG name from bugzilla to dfg_id in Polarion named_parms["d_f_g"] = convert_polarion_dfg(bug_dfg) #Get bug description from first comment and add to Polarion requirement desc = "" if bug_description: desc = Text( bug_description.encode('ascii', 'ignore').decode('ascii')) # decode("utf-8")) desc.content_type = "text/plain" # Add hyperlink to bugzilla link = Hyperlink() link.role = "ref_ext" link.uri = bug_link req = Requirement.create(project_id=POLARION_PRODUCT, title=bug_title, desc=desc, **named_parms) req.add_hyperlink(link.uri, link.role) req.status = "approved" req.update() #Get requirement ID and update bugzilla extrenal link tracker bz_connection.add_external_tracker( str(bz_rfe.id), str(req.work_item_id), ext_type_description="Polarion Requirement") req_ids.append(req.work_item_id) print "%s - end bug: %s" % (datetime.datetime.now(), bug_link) plan.add_plan_items(req_ids)
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_005_get_plan(self): plan = Plan(project_id=DEFAULT_PROJ, plan_id=PLAN_ID) self.assertEquals(plan.plan_id, PLAN_ID) plan2 = Plan(uri=plan.uri) self.assertEquals(plan2.plan_id, PLAN_ID)
def test_006_add_items(self): plan = Plan(project_id=DEFAULT_PROJ, plan_id=PLAN_ID) plan.add_plan_items([self.NEW_REQ, self.NEW_REQ2]) plan.reload() self.assertEquals(len(plan.records), 2)
def test_007_stats(self): plan = Plan(project_id=DEFAULT_PROJ, plan_id=PLAN_ID) stats = plan.get_statistics() self.assertEquals(stats.number_of_planned, 2)
def test_008_remove_wi(self): plan = Plan(project_id=DEFAULT_PROJ, plan_id=PLAN_ID) plan.remove_plan_items([self.NEW_REQ]) plan.reload() self.assertEquals(len(plan.records), 1) self.assertEquals(plan.records[0].item, self.NEW_REQ2)