def get_result_list(self, testcase_id, testrun_id=None, includedtestcase_list=None, tcassignment_list=None): if tcassignment_list is None: # we need to get it first if includedtestcase_list is None: # we need to get it first if testrun_id is None: assert False, "we need at least a testrun_id to fetch a result" includedtestcase_list = self.get_included_testcases(testrun_id) incl_testcase = verify_single_item_in_list(includedtestcase_list, "testCaseId", testcase_id) includedtestcase_id = get_resource_identity(incl_testcase)[0] tcassignment_list = self.get_testcase_assignments( includedtestcase_id) found_assignment = verify_single_item_in_list(tcassignment_list, "testCaseId", testcase_id) assignment_id = get_resource_identity(found_assignment)[0] return_list = self.get_list_from_endpoint("%s/assignments/%s/results" % \ (self.root_path, assignment_id), tcm_type = "testresult") # assert False, jstr(return_list) return return_list
def get_result_list(self, testcase_id, testrun_id = None, includedtestcase_list = None, tcassignment_list = None): if tcassignment_list is None: # we need to get it first if includedtestcase_list is None: # we need to get it first if testrun_id is None: assert False, "we need at least a testrun_id to fetch a result" includedtestcase_list = self.get_included_testcases(testrun_id) incl_testcase = verify_single_item_in_list(includedtestcase_list, "testCaseId", testcase_id) includedtestcase_id = get_resource_identity(incl_testcase)[0] tcassignment_list = self.get_testcase_assignments(includedtestcase_id) found_assignment = verify_single_item_in_list(tcassignment_list, "testCaseId", testcase_id) assignment_id = get_resource_identity(found_assignment)[0] return_list = self.get_list_from_endpoint("%s/assignments/%s/results" % \ (self.root_path, assignment_id), tcm_type = "testresult") # assert False, jstr(return_list) return return_list
def get_result_list(self, testcase_id, testrun_id = None, includedtestcase_list = None, tcassignment_list = None): ''' I *think* this is the best way to overload the method for several possible parameters. trying this technique ''' if tcassignment_list is None: # we need to get it first if includedtestcase_list is None: # we need to get it first if testrun_id is None: assert False, "we need at least a testrun_id to fetch a result" includedtestcase_list = self.get_included_testcases(testrun_id) incl_testcase = verify_single_item_in_list(includedtestcase_list, "testCaseId", testcase_id) includedtestcase_id = get_resource_identity(incl_testcase)[0] tcassignment_list = self.get_testcase_assignments(includedtestcase_id) found_assignment = verify_single_item_in_list(tcassignment_list, "testCaseId", testcase_id) assignment_id = get_resource_identity(found_assignment)[0] return self.get_list_from_endpoint("%s/assignments/%s/results" % \ (self.root_path, assignment_id), tcm_type = "testresult")
def search_and_verify(self, uri, search_args, expect_to_find, tcm_type=None): ''' This does a search based on the search_args passed in. So "expect_to_find" is really filtered based on those parameters. expect_to_find: If True, then we verify based on expecting to find something. If False, this will fail if we get a resultset greater than 0. ''' if tcm_type == None: tcm_type = self.singular resp_list = self.get_list_from_search(uri, params=search_args) if not expect_to_find: eq_(len(resp_list), 0, "expect result size zero:\n" + jstr(resp_list)) else: # we want to verify just ONE of the items returned. Indeed, we likely # expect only one. So we pick the first item returned verify_single_item_in_list(resp_list, params=search_args)
def testrun_has_environments(step, stored_testrun, testrun_name): testrunModel = TestrunModel() testrun = testrunModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = testrunModel.get_resid(testrun[ns("name")])[0] envgrp_list = testrunModel.get_environmentgroup_list(testrun_id) # walk through and verify that each environment is included for envgrp in step.hashes: # find that in the list of items verify_single_item_in_list(envgrp_list, "name", envgrp["name"])
def testrun_has_components(step, stored_testrun, testrun_name): testrunModel = TestrunModel() testrun = testrunModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] component_list = testrunModel.get_component_list(testrun_id) # walk through and verify that each testcase has the expected status for component in step.hashes: # find that in the list of testcases verify_single_item_in_list(component_list, "name", component["name"])
def testrun_has_testcases(step, stored_testrun, testrun_name): testrunModel = TestrunModel() testrun = testrunModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] # get the list of testcases for this testrun # get the list of testcases for this testrun includedtestcase_list = testrunModel.get_included_testcases(testrun_id) # walk through and verify that each testcase has the expected status for tc in step.hashes: testcase_id = TestcaseModel().get_resid(tc["name"])[0] # find that in the list of testcases verify_single_item_in_list(includedtestcase_list, "testCaseId", testcase_id)
def testcycle_has_team_members(step, stored_testcycle, testcycle_name, expect_any): testcycleModel = TestcycleModel() testcycle = testcycleModel.get_stored_or_store_obj(stored_testcycle, testcycle_name) testcycle_id = get_resource_identity(testcycle)[0] teammember_list = testcycleModel.get_team_members_list(testcycle_id) eq_list_length(teammember_list, step.hashes) for teammember in step.hashes: names = teammember["name"].split() verify_single_item_in_list(teammember_list, params = {"firstName": names[0], "lastName": names[1]} )
def create_role_with_permissions(step, stored, name): roleModel = RoleModel() name = roleModel.get_stored_or_store_name(stored, name) # create the new role role_payload = {"companyId": CompanyModel().get_seed_resid()[0], "name": name} roleModel.create(role_payload) #get the new role ID role_id, role_version = roleModel.get_resid(name) # get the list of all available permissions perm_array = PermissionModel().get_all_list() # walk the hash of permissionCodes add these to the new role for perm_code in step.hashes: permissionCode = perm_code["permissionCode"] # find the matching permission object based on the permissionCode field found_perm = verify_single_item_in_list(perm_array, "permissionCode", permissionCode) try: # there will always be only one that matches, in this case perm_id = found_perm[ns("resourceIdentity")]["@id"] except KeyError: assert False, "%s.%s not found in:\n%s" % (ns("resourceIdentity"), "@id", found_perm) # now add the permissions to that role roleModel.add_permission(role_id, role_version, perm_id)
def testcycle_has_testruns(step, stored_testcycle, testcycle_name, expect_any): testcycleModel = TestcycleModel() testcycle = testcycleModel.get_stored_or_store_obj(stored_testcycle, testcycle_name) testcycle_id = get_resource_identity(testcycle)[0] # get the list of testcases for this testcycle testrun_list = testcycleModel.get_testrun_list(testcycle_id) eq_list_length(testrun_list, step.hashes) # walk through and verify that each testcase has the expected status for testrun in step.hashes: # find that in the list of testcases exp_name = testrun["name"] verify_single_item_in_list(testrun_list, "name", exp_name)
def testrun_has_team_members(step, stored_testrun, testrun_name): testrunModel = TestrunModel() testrun = testrunModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] teammember_list = testrunModel.get_team_members_list(testrun_id) eq_list_length(teammember_list, step.hashes) for teammember in step.hashes: names = teammember["name"].split() verify_single_item_in_list(teammember_list, params={ "firstName": names[0], "lastName": names[1] })
def testcases_have_environments(step, stored_testrun, testrun_name): trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] # get the list of testcases for this testrun includedtestcase_list = trModel.get_included_testcases(testrun_id) for tc in step.hashes: testcase_id = TestcaseModel().get_resid(tc["name"])[0] result = trModel.get_result(testcase_id, includedtestcase_list = includedtestcase_list) testresult_id = get_resource_identity(result)[0] environments_list = trModel.get_result_environments_list(testresult_id) verify_single_item_in_list(environments_list, "name", tc["environment"])
def testcases_have_environments(step, stored_testrun, testrun_name): trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] # get the list of testcases for this testrun includedtestcase_list = trModel.get_included_testcases(testrun_id) for tc in step.hashes: testcase_id = TestcaseModel().get_resid(tc["name"])[0] result = trModel.get_result( testcase_id, includedtestcase_list=includedtestcase_list) testresult_id = get_resource_identity(result)[0] environments_list = trModel.get_result_environments_list(testresult_id) verify_single_item_in_list(environments_list, "name", tc["environment"])
def testcycle_has_environmentgroups(step, stored_testcycle, testcycle_name, expect_any): testcycleModel = TestcycleModel() testcycle = testcycleModel.get_stored_or_store_obj(stored_testcycle, testcycle_name) testcycle_id = get_resource_identity(testcycle)[0] # get the list of testcases for this testcycle envgrp_list = testcycleModel.get_environmentgroup_list(testcycle_id) # this checks that the lengths match. The expect_any holder is not used, but it allows for # alternate wording in the step. eq_list_length(envgrp_list, step.hashes) # walk through and verify that each testcase has the expected status for envgrp in step.hashes: # find that in the list of testcases exp_name = envgrp["name"] verify_single_item_in_list(envgrp_list, "name", exp_name)
def product_has_environmentgroups(step, stored_product, product_name, expect_any): productModel = ProductModel() product = productModel.get_stored_or_store_obj(stored_product, product_name) product_id = get_resource_identity(product)[0] # get the list of testcases for this product envgrp_list = productModel.get_environmentgroup_list(product_id) # this checks that the lengths match. The expect_any holder is not used, but it allows for # alternate wording in the step. eq_list_length(envgrp_list, step.hashes) # walk through and verify that each testcase has the expected status for envgrp in step.hashes: # find that in the list of testcases exp_name = envgrp["name"] verify_single_item_in_list(envgrp_list, "name", exp_name)
def search_and_verify(self, uri, search_args, expect_to_find, tcm_type = None): ''' This does a search based on the search_args passed in. So "expect_to_find" is really filtered based on those parameters. expect_to_find: If True, then we verify based on expecting to find something. If False, this will fail if we get a resultset greater than 0. ''' if tcm_type == None: tcm_type = self.singular resp_list = self.get_list_from_search(uri, params = search_args) if not expect_to_find: eq_(len(resp_list), 0, "expect result size zero:\n" + jstr(resp_list)) else: # we want to verify just ONE of the items returned. Indeed, we likely # expect only one. So we pick the first item returned verify_single_item_in_list(resp_list, params = search_args)
def get_result(self, testcase_id, testrun_id = None, includedtestcase_list = None, tcassignment_list = None, result_list = None): if result_list == None: result_list = self.get_result_list(testcase_id, testrun_id = testrun_id, includedtestcase_list = includedtestcase_list, tcassignment_list = tcassignment_list) result = verify_single_item_in_list(result_list, "testCaseId", testcase_id) return result
def assign_testcase(self, testrun_name, user_id, testcase_name): testrun_id, testrun_version = self.get_resid(testrun_name) testcase_id = TestcaseModel().get_resid(testcase_name)[0] # get the list of testcases for this testrun includedtestcase_list = self.get_included_testcases(testrun_id) # find that in the list of testcases includedtestcase = verify_single_item_in_list(includedtestcase_list, "testCaseId", testcase_id) includedtestcase_id = get_resource_identity(includedtestcase)[0] post_uri = "%s/includedtestcases/%s/assignments/" % (self.root_path, includedtestcase_id) body = {"testerId": user_id, "originalVersionId": testrun_version} do_post(post_uri, body)
def get_result(self, testcase_id, testrun_id=None, includedtestcase_list=None, tcassignment_list=None, result_list=None): if result_list == None: result_list = self.get_result_list( testcase_id, testrun_id=testrun_id, includedtestcase_list=includedtestcase_list, tcassignment_list=tcassignment_list) result = verify_single_item_in_list(result_list, "testCaseId", testcase_id) return result
def testrun_has_summary_counts(step, stored_testrun, testrun_name): trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) # get the list of testcases for this testrun summary_list = trModel.get_summary_list(testrun) # walk through and verify that each testcase has the expected status for category in step.hashes: # find that in the list of testcases status_id = get_result_status_id(category["name"]) categoryInfo = verify_single_item_in_list(summary_list, "categoryName", status_id) assert str(categoryInfo[ns("categoryValue")]) == category["count"], \ "%s count was wrong. Expected categoryName: %s , categoryValue: %s:\n%s" % \ (category["name"], status_id, category["count"], jstr(categoryInfo))
def assign_testcase(self, testrun_name, user_id, testcase_name): testrun_id, testrun_version = self.get_resid(testrun_name) testcase_id = TestcaseModel().get_resid(testcase_name)[0] # get the list of testcases for this testrun includedtestcase_list = self.get_included_testcases(testrun_id) # find that in the list of testcases includedtestcase = verify_single_item_in_list(includedtestcase_list, "testCaseId", testcase_id) includedtestcase_id = get_resource_identity(includedtestcase)[0] post_uri = "%s/includedtestcases/%s/assignments/" % ( self.root_path, includedtestcase_id) body = {"testerId": user_id, "originalVersionId": testrun_version} do_post(post_uri, body)
def testcases_have_pending_result_statuses(step, stored_testrun, testrun_name): trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] status_id = get_result_status_id("Pending") # get the list of testcases for this testrun result_list = trModel.search_for_results_by_result_status(testrun_id, status_id) eq_list_length(result_list, step.hashes) for tc in step.hashes: testcase_id = TestcaseModel().get_resid(tc["name"])[0] result = verify_single_item_in_list(result_list, "testCaseId", testcase_id) # ok, we have the tc result in question, now check that its status matches expectations eq_(result[ns("testRunResultStatusId")], status_id, "testRunResultStatusId check")
def testcases_have_pending_result_statuses(step, stored_testrun, testrun_name): trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] status_id = get_result_status_id("Pending") # get the list of testcases for this testrun result_list = trModel.search_for_results_by_result_status( testrun_id, status_id) eq_list_length(result_list, step.hashes) for tc in step.hashes: testcase_id = TestcaseModel().get_resid(tc["name"])[0] result = verify_single_item_in_list(result_list, "testCaseId", testcase_id) # ok, we have the tc result in question, now check that its status matches expectations eq_(result[ns("testRunResultStatusId")], status_id, "testRunResultStatusId check")