def get_single_item_from_endpoint(self, uri=None, tcm_type=None, params={}, headers=get_json_headers()): ''' This hits an endpoint. No searchResult or ArrayOfXXXX part here ''' if uri == None: uri = self.root_path if tcm_type == None: tcm_type = self.singular response_txt = do_get(uri, params=params, headers=headers) tcm_obj = json_to_obj(response_txt) try: item = tcm_obj[ns(tcm_type)][0] # we only want to store this latest item, if it's an object of this type. If this # model is doing a search for a different type of item (like percent complete object # of "CategoryValueInfo" then we don't want to store it as "latest item" if uri == self.root_path: self.store_latest(item) return item except KeyError: assert False, "%s\nDidn't find %s in %s" % ( str(KeyError), ns(tcm_type), jstr(tcm_obj))
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 get_list_from_endpoint(self, uri, tcm_type = None, headers = get_json_headers()): ''' This hits an endpoint. It goes into the ArrayOfXXX tcm_type of response ''' if tcm_type == None: tcm_type = self.singular response_txt = do_get(uri, headers = headers) try: array_of_type = json_to_obj(response_txt)[ns(as_arrayof(tcm_type))][0] if (len(array_of_type) > 1): items = array_of_type[ns(tcm_type)] if (not isinstance(items, list)): items = [items] else: items = [] return items except (KeyError, TypeError) as err: assert False, \ "%s\nDidn't find [%s][0][%s] in\n%s" % \ (str(err), ns(as_arrayof(tcm_type)), ns(tcm_type), json_pretty(response_txt))
def get_single_item_from_endpoint(self, uri = None, tcm_type = None, params = {}, headers = get_json_headers()): ''' This hits an endpoint. No searchResult or ArrayOfXXXX part here ''' if uri == None: uri = self.root_path if tcm_type == None: tcm_type = self.singular response_txt = do_get(uri, params = params, headers = headers) tcm_obj = json_to_obj(response_txt) try: item = tcm_obj[ns(tcm_type)][0] # we only want to store this latest item, if it's an object of this type. If this # model is doing a search for a different type of item (like percent complete object # of "CategoryValueInfo" then we don't want to store it as "latest item" if uri == self.root_path: self.store_latest(item) return item except KeyError: assert False, "%s\nDidn't find %s in %s" % (str(KeyError), ns(tcm_type), jstr(tcm_obj))
def get_list_from_endpoint(self, uri, tcm_type=None, params={}, headers=get_json_headers()): ''' This hits an endpoint. It goes into the ArrayOfXXX tcm_type of response ''' if tcm_type == None: tcm_type = self.singular response_txt = do_get(uri, params=params, headers=headers) try: array_of_type = json_to_obj(response_txt)[ns( as_arrayof(tcm_type))][0] if (len(array_of_type) > 1): items = array_of_type[ns(tcm_type)] if (not isinstance(items, list)): items = [items] else: items = [] return items except (KeyError, TypeError) as err: assert False, \ "%s\nDidn't find [%s][0][%s] in\n%s" % \ (str(err), ns(as_arrayof(tcm_type)), ns(tcm_type), json_pretty(response_txt))
def logged_in_as_user(step, stored, name): userModel = UserModel() name = userModel.get_stored_or_store_name(stored, name) names = name.split() thisUser = userModel.get_logged_in_user() eq_(thisUser[ns("firstName")], names[0], "First Name field didn't match") eq_(thisUser[ns("lastName")], names[1], "Last Name field didn't match")
def testcase_has_status_of_approved(step, stored, testcase_name): tcModel = TestcaseModel() testcase_name = tcModel.get_stored_or_store_name(stored, testcase_name) # fetch the steps for this testcase from the latestversion testcase_id = tcModel.get_resid(testcase_name)[0] testcaseversion = tcModel.get_latestversion(testcase_id) # should be just one try: eq_(testcaseversion[ns("approvalStatusId")], 2, "Testcase is approved: " + str(testcaseversion)) except KeyError: assert False, "Object field mismatch.\nExpected:\n" + ns("approved") + "\n\nActual:\n" + jstr(testcaseversion)
def testcases_have_approval_statuses(step): tcModel = TestcaseModel() for tc in step.hashes: testcase_id = tcModel.get_resid(tc["name"])[0] testcaseversion = tcModel.get_latestversion(testcase_id) # should be just one try: eq_(testcaseversion[ns("approvalStatusId")], 2, "Testcase is approved: " + str(testcaseversion)) except KeyError: assert False, "Object field mismatch.\nExpected:\n" + ns("approved") + "\n\nActual:\n" + jstr(testcaseversion)
def testcases_have_approval_statuses(step): tcModel = TestcaseModel() for tc in step.hashes: testcase_id = tcModel.get_resid(tc["name"])[0] testcaseversion = tcModel.get_latestversion(testcase_id) # should be just one try: eq_(testcaseversion[ns("approvalStatusId")], 2, "Testcase is approved: " + str(testcaseversion)) except KeyError: assert False, "Object field mismatch.\nExpected:\n" + ns( "approved") + "\n\nActual:\n" + jstr(testcaseversion)
def testcase_has_status_of_approved(step, stored, testcase_name): tcModel = TestcaseModel() testcase_name = tcModel.get_stored_or_store_name(stored, testcase_name) # fetch the steps for this testcase from the latestversion testcase_id = tcModel.get_resid(testcase_name)[0] testcaseversion = tcModel.get_latestversion(testcase_id) # should be just one try: eq_(testcaseversion[ns("approvalStatusId")], 2, "Testcase is approved: " + str(testcaseversion)) except KeyError: assert False, "Object field mismatch.\nExpected:\n" + ns( "approved") + "\n\nActual:\n" + jstr(testcaseversion)
def at_least_these_environments_exist(step): model = EnvironmentModel() env_list = model.get_all_list() # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for env in step.hashes: env_name = env["name"] envtype_id = EnvironmenttypeModel().get_resid(env["type"])[0] found_env = [x for x in env_list if ((x[ns("name")] == env_name) and (x[ns("environmentTypeId")] == envtype_id))] assert (len(found_env) == 1), \ "Expected to find environment with name %s and environmentTypeId of %s in:\n%s" % \ (env_name, envtype_id, jstr(env_list))
def find_role_by_id(step, stored_role, role_name): roleModel = RoleModel() role_name = roleModel.get_stored_or_store_name(stored_role, role_name) role = roleModel.get_by_name(role_name) assert role[ns("name")] == role_name, "Expected to find role with name %s in:\n%s" % (role_name, jstr(role))
def create(self, params, headers = get_form_headers()): data = do_post(self.root_path, params, headers = headers) try: created_obj = json_to_obj(data)[ns(self.creation_key)][0] except KeyError: assert False, "looking for %s in:\n%s" % (self.creation_key, json_pretty(data)) self.store_latest(created_obj) return created_obj
def start_testcase(self, result_obj, user_name): result_id, result_version = get_resource_identity(result_obj) # start the test headers = get_form_headers(UserModel().get_auth_header(user_name)) testresult = do_put("%s/results/%s/start" % (self.root_path, result_id), {"originalVersionId": result_version}, headers) started_result = json_to_obj(testresult)[ns("testresult")][0] return started_result
def testcycle_has_testrun(step, cycle_name, run_name): testcycleModel = TestcycleModel() testcycle_id = testcycleModel.get_resid(cycle_name)[0] testrun_list = testcycleModel.get_testrun_list(testcycle_id) found_run = [x for x in testrun_list if x[ns("name")] == run_name] assert len(found_run) == 1, "Expected to find name %s in:\n%s" % (run_name, jstr(testrun_list))
def check_group_environmenttype_with_name(step, stored, name, is_group): envtypeModel = EnvironmenttypeModel() name = envtypeModel.get_stored_or_store_name(stored, name) groupType = (is_group.strip() == "a group") env_type = envtypeModel.get_by_name(name) eq_(env_type[ns("groupType")], groupType, "GroupType match check")
def testcycle_has_percent_complete_of_X(step, stored_testcycle, testcycle_name, exp_percent): 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 act_percent = testcycleModel.get_percent_complete(testcycle_id) eq_(act_percent[ns("categoryValue")], int(exp_percent), "percent complete check")
def testcycle_has_testrun(step, cycle_name, run_name): testcycleModel = TestcycleModel() testcycle_id = testcycleModel.get_resid(cycle_name)[0] testrun_list = testcycleModel.get_testrun_list(testcycle_id) found_run = [x for x in testrun_list if x[ns("name")] == run_name] assert len(found_run) == 1, "Expected to find name %s in:\n%s" % ( run_name, jstr(testrun_list))
def create(self, params, headers=get_form_headers()): data = do_post(self.root_path, params, headers=headers) try: created_obj = json_to_obj(data)[ns(self.creation_key)][0] except KeyError: assert False, "looking for %s in:\n%s" % (self.creation_key, json_pretty(data)) self.store_latest(created_obj) return created_obj
def start_testcase(self, result_obj, user_name): result_id, result_version = get_resource_identity(result_obj) # start the test headers = get_form_headers(UserModel().get_auth_header(user_name)) testresult = do_put( "%s/results/%s/start" % (self.root_path, result_id), {"originalVersionId": result_version}, headers) started_result = json_to_obj(testresult)[ns("testresult")][0] return started_result
def get_auth_header(self, user_name): names = user_name.split() user_list = self.get_list_from_search(self.root_path, params = {"firstName": names[0], "lastName": names[1]}) try: useremail = user_list[0][ns("email")] userpw = get_user_password(user_name) except KeyError: assert False, "%s\nDidn't find field in %s" % (str(KeyError), user_list) return get_auth_header(useremail, userpw)
def has_role(self, user_name, role_name): ''' This doesn't use the search_and_verify. Not sure if this is the better approach or not. May need to decide on one. ''' role_list = self.get_role_list(user_name) found_role = [x for x in role_list if x[ns("name")] == role_name] assert len(found_role) == 1, "Expected to find role with name %s in:\n%s" % (role_name, str(role_list))
def at_least_these_companys_exist(step): company_list = CompanyModel().get_all_list() # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for company in step.hashes: found_company = [x for x in company_list if x[ns("name")] == company["name"]] assert len(found_company) == 1, "Expected to find company named %s in:\n%s" % (company["name"], str(company_list))
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 get_list_from_search(self, uri, tcm_type=None, plural_tcm_type=None, params={}, headers=get_json_headers()): ''' This will always return an array. May have many, one or no items in it it goes into the "searchResult" tcm_type of response ''' if tcm_type == None: tcm_type = self.singular plural_tcm_type = self.plural if plural_tcm_type == None: plural_tcm_type = plural(tcm_type) response_txt = do_get(uri, params, headers) sr_field = ns("searchResult") tcm_type = ns(tcm_type) pl_type = ns(plural_tcm_type) try: sr = json_to_obj(response_txt)[sr_field][0] if (sr[ns("totalResults")] > 0): items = sr[pl_type][tcm_type] if (not isinstance(items, list)): items = [items] else: items = [] return items except (KeyError, TypeError) as err: assert False, \ "%s\nDidn't find [%s][0][%s][%s] in\n%s" % \ (str(err), sr_field, pl_type, ns(tcm_type), json_pretty(response_txt))
def get_list_from_search(self, uri, tcm_type = None, plural_tcm_type = None, params = {}, headers = get_json_headers()): ''' This will always return an array. May have many, one or no items in it it goes into the "searchResult" tcm_type of response ''' if tcm_type == None: tcm_type = self.singular plural_tcm_type = self.plural if plural_tcm_type == None: plural_tcm_type = plural(tcm_type) response_txt = do_get(uri, params, headers) sr_field = ns("searchResult") tcm_type = ns(tcm_type) pl_type = ns(plural_tcm_type) try: sr = json_to_obj(response_txt)[sr_field][0] if (sr[ns("totalResults")] > 0): items = sr[pl_type][tcm_type] if (not isinstance(items, list)): items = [items] else: items = [] return items except (KeyError, TypeError) as err: assert False, \ "%s\nDidn't find [%s][0][%s][%s] in\n%s" % \ (str(err), sr_field, pl_type, ns(tcm_type), json_pretty(response_txt))
def has_role(self, user_name, role_name): ''' This doesn't use the search_and_verify. Not sure if this is the better approach or not. May need to decide on one. ''' role_list = self.get_role_list(user_name) found_role = [x for x in role_list if x[ns("name")] == role_name] assert len( found_role) == 1, "Expected to find role with name %s in:\n%s" % ( role_name, str(role_list))
def testrun_results_have_approval_statuses(step, stored_testrun, testrun_name): testrunModel = TestrunModel() testcaseModel = TestcaseModel() testrun = testrunModel.get_stored_or_store_obj(stored_testrun, testrun_name) testrun_id = get_resource_identity(testrun)[0] for testcase in step.hashes: testcase_id = testcaseModel.get_resid(testcase["name"])[0] result_obj = testrunModel.get_result(testcase_id, testrun_id) eq_(result_obj[ns("approvalStatusId")], get_approval_status_id(testcase["status"]), "Wrong approvalStatusId for result. Expected:\n%s" % testcase)
def check_roles_exist(hashes): roleModel = RoleModel() role_list = roleModel.get_all_list() # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for role in hashes: role_name = role["name"] found_perm = [x for x in role_list if x[ns("name")] == role_name] assert len(found_perm) == 1, "Expected to find role name %s in:\n%s" % (role_name, jstr(role_list))
def get_single_item_from_endpoint(self, uri = None, tcm_type = None, headers = get_json_headers()): ''' This hits an endpoint. No searchResult or ArrayOfXXXX part here ''' if uri == None: uri = self.root_path if tcm_type == None: tcm_type = self.singular response_txt = do_get(uri, headers = headers) tcm_obj = json_to_obj(response_txt) try: item = tcm_obj[ns(tcm_type)][0] self.store_latest(item) return item except KeyError: assert False, "%s\nDidn't find %s in %s" % (str(KeyError), ns(tcm_type), jstr(tcm_obj))
def role_has_permissions(step, stored, role_name): roleModel = RoleModel() role_name = roleModel.get_stored_or_store_name(stored, role_name) perm_list = roleModel.get_permissions_list(role_name) # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for perm_code in step.hashes: permissionCode = perm_code["permissionCode"] found_perm = [x for x in perm_list if x[ns("permissionCode")] == permissionCode] assert len(found_perm) == 1, "Expected to find permissionCode %s in:\n%s" % (permissionCode, str(perm_list))
def verify_testcase_steps(step, stored, name): tcModel = TestcaseModel() name = tcModel.get_stored_or_store_name(stored, name) testcasestep_list = tcModel.get_latest_steps_list(name) # compare the returned values with those passed in to verify match step_num = 0 try: for exp_step in step.hashes: act_step = testcasestep_list[step_num] eq_(act_step[ns("name")], exp_step["name"], "name match") step_num += 1 except KeyError: assert False, "Object field mismatch.\nExpected:\n" + jstr(step.hashes) + "\n\nActual:\n" + jstr(testcasestep_list)
def get_auth_header(self, user_name): names = user_name.split() user_list = self.get_list_from_search(self.root_path, params={ "firstName": names[0], "lastName": names[1] }) try: useremail = user_list[0][ns("email")] userpw = get_user_password(user_name) except KeyError: assert False, "%s\nDidn't find field in %s" % (str(KeyError), user_list) return get_auth_header(useremail, userpw)
def testcase_has_attachment(step, test_case, haveness, attachment): # fetch the test case's resource identity testcaseModel = TestcaseModel() testcase_id = testcaseModel.get_resid(test_case)[0] result_list = testcaseModel.get_attachment_list(testcase_id) #@todo: this should be abstracted into a helper method or in the model found_item = [x for x in result_list if x[ns("name")] == attachment] if (haveness == "has"): assert len(found_item) == 1, "Expected to find %s in:\n%s" % (attachment, jstr(result_list)) else: assert len(found_item) == 0, "Expected to NOT find %s in:\n%s" % (attachment, jstr(result_list))
def testcase_has_attachment(step, test_case, haveness, attachment): # fetch the test case's resource identity testcaseModel = TestcaseModel() testcase_id = testcaseModel.get_resid(test_case)[0] result_list = testcaseModel.get_attachment_list(testcase_id) #@todo: this should be abstracted into a helper method or in the model found_item = [x for x in result_list if x[ns("name")] == attachment] if (haveness == "has"): assert len(found_item) == 1, "Expected to find %s in:\n%s" % ( attachment, jstr(result_list)) else: assert len(found_item) == 0, "Expected to NOT find %s in:\n%s" % ( attachment, jstr(result_list))
def remember_the_url_for_the_testcase_result(step, stored_testcase, testcase_name, stored_testrun, testrun_name): trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) tcModel = TestcaseModel() testcase = tcModel.get_stored_or_store_obj(stored_testcase, testcase_name) testrun_id = get_resource_identity(testrun)[0] testcase_id = get_resource_identity(testcase)[0] # get the list of testcases for this testrun includedtestcase_list = trModel.get_included_testcases(testrun_id) result = trModel.get_result(testcase_id, includedtestcase_list = includedtestcase_list) testresult_url = result[ns("resourceIdentity")]["@url"] get_stored_or_store_field("url", "testcaseRunResult", "", testresult_url)
def verify_testcase_steps(step, stored, name): tcModel = TestcaseModel() name = tcModel.get_stored_or_store_name(stored, name) testcasestep_list = tcModel.get_latest_steps_list(name) # compare the returned values with those passed in to verify match step_num = 0 try: for exp_step in step.hashes: act_step = testcasestep_list[step_num] eq_(act_step[ns("name")], exp_step["name"], "name match") step_num += 1 except KeyError: assert False, "Object field mismatch.\nExpected:\n" + jstr( step.hashes) + "\n\nActual:\n" + jstr(testcasestep_list)
def foo_has_these_assignments(step, stored, name): userModel = UserModel() name = userModel.get_stored_or_store_name(stored, name) user_id = userModel.get_resid(name)[0] assignment_list = userModel.get_assignment_list(user_id) # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for role in step.hashes: role_name = role["name"] found_perm = [x for x in assignment_list if x[ns("name")] == role_name] assert len(found_perm) == 1, "Expected to find assignment name %s in:\n%s" % (role_name, jstr(assignment_list))
def foo_has_these_assignments(step, stored, name): userModel = UserModel() name = userModel.get_stored_or_store_name(stored, name) user_id = userModel.get_resid(name)[0] assignment_list = userModel.get_assignment_list(user_id) # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for role in step.hashes: role_name = role["name"] found_perm = [x for x in assignment_list if x[ns("name")] == role_name] assert len( found_perm) == 1, "Expected to find assignment name %s in:\n%s" % ( role_name, jstr(assignment_list))
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 user_has_permissions(step, stored, user_name, at_least_only): userModel = UserModel() user_name = userModel.get_stored_or_store_name(stored, user_name) perm_list = userModel.get_permission_list(user_name) list_size_check(at_least_only, step.hashes, perm_list) # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for perm_code in step.hashes: permissionCode = perm_code["permissionCode"] found_perm = [x for x in perm_list if x[ns("permissionCode")] == permissionCode] assert len(found_perm) == 1, "Expected to find permissionCode %s in:\n%s" % (permissionCode, str(perm_list))
def user_has_these_roles(step, stored_user, user_name, at_least_only): userModel = UserModel() user_name = userModel.get_stored_or_store_name(stored_user, user_name) role_list = userModel.get_role_list(user_name) list_size_check(at_least_only, step.hashes, role_list) # walk through all the expected roles and make sure it has them all # note, it doesn't check that ONLY these roles exist. That should be a different # method. for role in step.hashes: role_name = role["name"] found_perm = [x for x in role_list if x[ns("name")] == role_name] assert len(found_perm) == 1, "Expected to find role name %s in:\n%s" % (role_name, jstr(role_list))
def testcases_have_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] # 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) # ok, we have the tc result in question, now check that its status matches expectations eq_(result[ns("testRunResultStatusId")], get_result_status_id(tc["status"]), "testRunResultStatusId check")
def remember_the_url_for_the_testcase_result(step, stored_testcase, testcase_name, stored_testrun, testrun_name): trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) tcModel = TestcaseModel() testcase = tcModel.get_stored_or_store_obj(stored_testcase, testcase_name) testrun_id = get_resource_identity(testrun)[0] testcase_id = get_resource_identity(testcase)[0] # get the list of testcases for this testrun includedtestcase_list = trModel.get_included_testcases(testrun_id) result = trModel.get_result(testcase_id, includedtestcase_list=includedtestcase_list) testresult_url = result[ns("resourceIdentity")]["@url"] get_stored_or_store_field("url", "testcaseRunResult", "", testresult_url)
def testcases_have_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] # 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) # ok, we have the tc result in question, now check that its status matches expectations eq_(result[ns("testRunResultStatusId")], get_result_status_id(tc["status"]), "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")
def check_url_for_the_testcase_result_has_not_changed(step, stored_testcase, testcase_name, stored_testrun, testrun_name): stored_url = get_stored_or_store_field("url", "testcaseRunResult", "that url", None) trModel = TestrunModel() testrun = trModel.get_stored_or_store_obj(stored_testrun, testrun_name) tcModel = TestcaseModel() testcase = tcModel.get_stored_or_store_obj(stored_testcase, testcase_name) testrun_id = get_resource_identity(testrun)[0] testcase_id = get_resource_identity(testcase)[0] # get the list of testcases for this testrun includedtestcase_list = trModel.get_included_testcases(testrun_id) result = trModel.get_result(testcase_id, includedtestcase_list=includedtestcase_list) testresult_url = result[ns("resourceIdentity")]["@url"] eq_(testresult_url, stored_url, "testRunResult URL check")