def user_approves_testcases(step, stored_user, user_name):
    user_name = get_stored_or_store_name("user", stored_user, user_name)

    tcModel = TestcaseModel()

    for tc in step.hashes:
        tcModel.approve_by_user(tc["name"], user_name)
def user_approves_testcases(step, stored_user, user_name):
    user_name = get_stored_or_store_name("user", stored_user, user_name)

    tcModel = TestcaseModel()

    for tc in step.hashes:
        tcModel.approve_by_user(tc["name"], user_name)
def user_approves_testcase(step, stored_user, user_name, stored_testcase,
                           testcase_name):
    testcase_name = get_stored_or_store_name("testcase", stored_testcase,
                                             testcase_name)
    user_name = get_stored_or_store_name("user", stored_user, user_name)

    tcModel = TestcaseModel()
    tcModel.approve_by_user(testcase_name, user_name)
def approve_result_for_testrun(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]

        testrunModel.approve_result(testrun_id, testcase_id)
def create_testcase_with_name(step, stored, name):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)

    post_payload = {"productId": ProductModel().get_seed_resid()[0],
                    "maxAttachmentSizeInMbytes":"10",
                    "maxNumberOfAttachments":"5",
                    "name": name,
                    "description": "Lettuce tc"
                   }
    testcaseModel.create(post_payload)
def approve_result_for_testrun(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]

        testrunModel.approve_result(testrun_id, testcase_id)
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 create_testcase_with_name(step, stored, name):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)

    post_payload = {
        "productId": ProductModel().get_seed_resid()[0],
        "maxAttachmentSizeInMbytes": "10",
        "maxNumberOfAttachments": "5",
        "name": name,
        "description": "Lettuce tc"
    }
    testcaseModel.create(post_payload)
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 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 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 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 user_creates_testcase_with_name(step, stored_user, user_name, stored_testcase, testcase_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)
    testcaseModel = TestcaseModel()
    testcase_name = testcaseModel.get_stored_or_store_name(stored_testcase, testcase_name)

    post_payload = {"productId": ProductModel().get_seed_resid()[0],
                    "maxAttachmentSizeInMbytes":"10",
                    "maxNumberOfAttachments":"5",
                    "name": testcase_name,
                    "description": "Lettuce tc"
                    }
    headers = get_form_headers(userModel.get_auth_header(user_name))

    testcaseModel.create(post_payload, headers)
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 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 user_marks_testcase_status(step, stored_user, user_name, stored_testrun,
                               testrun_name):
    trModel = TestrunModel()
    testrun_name = trModel.get_stored_or_store_name(stored_testrun,
                                                    testrun_name)
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)

    # first we need the testrun id so we can get the latest version to approve
    #    user_id = UserModel().get_resid(user_name)[0]
    testrun_id = trModel.get_resid(testrun_name)[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_obj = trModel.get_result(
            testcase_id, includedtestcase_list=includedtestcase_list)
        result_id = get_resource_identity(result_obj)[0]

        started_result = trModel.start_testcase(result_obj, user_name)
        started_result_version = get_resource_identity(started_result)[1]
        # now finally mark it with the specified status

        trModel.set_testcase_status(result_id, started_result_version,
                                    user_name, tc["status"])
def retest_for_testcases(step, stored_testrun, testrun_name):
    '''
        Step hashes can have a user name field or not.  If it's not specified, it will,
        obviously, not pass a user id, so it will assign the new result object to the
        user of the previous result.
    '''
    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]

        try:
            tester_id = UserModel().get_resid(tc["user name"])[0]

        except KeyError:
            tester_id = None

        result = trModel.get_result(
            testcase_id, includedtestcase_list=includedtestcase_list)

        result_id = get_resource_identity(result)[0]

        trModel.retest_single(result_id, tester_id)
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 fetch_results_by_ids(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:
        # for each testcase name, fetch the result that matches it in the testrun list
        testcase_obj = testcaseModel.get_by_name(testcase["name"])
        testcase_id = get_resource_identity(testcase_obj)[0]

        result_from_list = testrunModel.get_result(testcase_id,
                                                   testrun_id = testrun_id)
        testresult_id = get_resource_identity(result_from_list)[0]
        result_from_endpoint = testrunModel.get_result_by_id(testresult_id)
        compare_dicts_by_keys(result_from_list, result_from_endpoint, ("testCaseId", "testRunId", "testSuiteId"))
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 user_creates_testcase_with_name(step, stored_user, user_name,
                                    stored_testcase, testcase_name):
    userModel = UserModel()
    user_name = userModel.get_stored_or_store_name(stored_user, user_name)
    testcaseModel = TestcaseModel()
    testcase_name = testcaseModel.get_stored_or_store_name(
        stored_testcase, testcase_name)

    post_payload = {
        "productId": ProductModel().get_seed_resid()[0],
        "maxAttachmentSizeInMbytes": "10",
        "maxNumberOfAttachments": "5",
        "name": testcase_name,
        "description": "Lettuce tc"
    }
    headers = get_form_headers(userModel.get_auth_header(user_name))

    testcaseModel.create(post_payload, headers)
def fetch_results_by_ids(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:
        # for each testcase name, fetch the result that matches it in the testrun list
        testcase_obj = testcaseModel.get_by_name(testcase["name"])
        testcase_id = get_resource_identity(testcase_obj)[0]

        result_from_list = testrunModel.get_result(testcase_id,
                                                   testrun_id=testrun_id)
        testresult_id = get_resource_identity(result_from_list)[0]
        result_from_endpoint = testrunModel.get_result_by_id(testresult_id)
        compare_dicts_by_keys(result_from_list, result_from_endpoint,
                              ("testCaseId", "testRunId", "testSuiteId"))
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 add_steps_to_testcase_name(step, stored, name):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)
    # first we need the testcase id so we can get the latest version to add steps to
    testcase_id = testcaseModel.get_resid(name)[0]
    testcaseversion_id = testcaseModel.get_latestversion_resid(testcase_id)[0]

    testcaseModel.add_steps(testcaseversion_id, step.hashes)
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")
def add_steps_to_testcase_name(step, stored, name):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)
    # first we need the testcase id so we can get the latest version to add steps to
    testcase_id = testcaseModel.get_resid(name)[0]
    testcaseversion_id = testcaseModel.get_latestversion_resid(testcase_id)[0]

    testcaseModel.add_steps(testcaseversion_id, step.hashes)
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")
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 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_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_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")
Example #34
0
def upload_attachment_foo_to_test_case_bar(step, filename, stored, name):
    testcaseModel = TestcaseModel()
    testcase = testcaseModel.get_stored_or_store_obj(stored, name)
    testcaseModel.upload_attachment(filename, testcase)
def activate_testcases(step):

    tcModel = TestcaseModel()

    for tc in step.hashes:
        tcModel.activate(tc["name"])
def user_approves_testcase(step, stored_user, user_name, stored_testcase, testcase_name):
    testcase_name = get_stored_or_store_name("testcase", stored_testcase, testcase_name)
    user_name = get_stored_or_store_name("user", stored_user, user_name)

    tcModel = TestcaseModel()
    tcModel.approve_by_user(testcase_name, user_name)
def check_testcase_foo_existence(step, stored, name, existence):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)
    testcaseModel.verify_existence_on_root (name,
                                              existence = existence)
def activate_testcase_with_name(step, stored, name):
    tcModel = TestcaseModel()
    name = tcModel.get_stored_or_store_name(stored, name)

    tcModel.activate(name)
def check_testcase_foo_existence(step, stored, name, existence):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)
    testcaseModel.verify_existence_on_root(name, existence=existence)
def activate_testcases(step):

    tcModel = TestcaseModel()

    for tc in step.hashes:
        tcModel.activate(tc["name"])
def delete_testcase_with_name_foo(step, stored, name):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)

    testcaseModel.delete(name)
def activate_testcase_with_name(step, stored, name):
    tcModel = TestcaseModel()
    name = tcModel.get_stored_or_store_name(stored, name)

    tcModel.activate(name)
def upload_attachment_foo_to_test_case_bar(step, filename, stored, name):
    testcaseModel = TestcaseModel()
    testcase = testcaseModel.get_stored_or_store_obj(stored, name)
    testcaseModel.upload_attachment(filename, testcase)
def delete_testcase_with_name_foo(step, stored, name):
    testcaseModel = TestcaseModel()
    name = testcaseModel.get_stored_or_store_name(stored, name)

    testcaseModel.delete(name)