def create_seed_company_and_product(step):
    names = step.hashes[0]

    # create the seed company
    company = world.seed_company.copy()
    # use the value passed in, in case it's different than the default
    company["name"] = names["company name"]
    world.names["company"] = company["name"]

    #TODO: not able to search for the country name yet
    company["countryId"] = 123
    if company.has_key("country name"):
        del company["country name"]

    companyModel = CompanyModel()
    companyModel.create(company)

    # create the seed product
    # persist the last one we make.  Sometimes we will only make one.
    product = world.seed_product.copy()
    product["name"] = names["product name"]
    world.names["product"] = product["name"]

    # get the company id from the passed company name
    company_id = CompanyModel().get_resid(product["company name"])[0]
    product["companyId"] = company_id
    if product.has_key("company name"):
        del product["company name"]

    productModel = ProductModel()
    productModel.create(product)
def product_has_environementgroup(step, stored_prod, prod_name, haveness, stored_envgrp, envgrp_name):
    prod_name = get_stored_or_store_name("product", stored_prod, prod_name)
    envgrp_name  = get_stored_or_store_name("environmentgroup", stored_envgrp, envgrp_name)

    # this url needs to search for environment groups for that product
    # should be products/{id}/environmentgroups
    productModel = ProductModel()

    productModel.verify_has_environmentgroup(prod_name, envgrp_name,(haveness == "has"))
def create_product_with_name_foo(step, stored, name):
    productModel = ProductModel()
    name = productModel.get_stored_or_store_name(stored, name)

    post_payload = {"companyId": CompanyModel().get_seed_resid()[0],
                    "name": name,
                    "description": "Lettuce Product Description"
                   }
    productModel.create(post_payload)
def add_envgroups_to_product(step, stored_product, product_name):
    productModel = ProductModel()
    product_name = productModel.get_stored_or_store_name(stored_product, product_name)

    envgrp_ids = []
    for envgrp in step.hashes:
        envgrp_id = EnvironmentgroupModel().get_resid(envgrp["name"])[0]
        envgrp_ids.append(envgrp_id)

    productModel.add_environmentgroups(product_name, envgrp_ids)
def create_products(step):
    productModel = ProductModel()

    for item in step.hashes:
        # must copy the item, because we change it, and that freaks lettuce out
        # when it displays results
        product = item.copy()
        # persist the last one we make.  Sometimes we will only make one.
        world.names["product"] = product["name"]

        # get the company id from the passed company name
        company_id = CompanyModel().get_resid(product["company name"])[0]
        product["companyId"] = company_id
        del product["company name"]

        productModel.create(product)
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 create_testsuite_with_name(step, stored, name):
    testsuiteModel = TestsuiteModel()
    name = testsuiteModel.get_stored_or_store_name(stored, name)

    post_payload = {
        "productId": ProductModel().get_seed_resid()[0],
        "name": name,
        "description": "Sweet Relief",
        "useLatestVersions": "true"
    }
    testsuiteModel.create(post_payload)
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)
Example #9
0
def create_testcycle_with_name(step, stored, name):
    testcycleModel = TestcycleModel()
    name = testcycleModel.get_stored_or_store_name(stored, name)

    post_payload = {
        "name": name,
        "description": "Ahh, the cycle of life...",
        "productId": ProductModel().get_seed_resid()[0],
        "startDate": "2011/02/02",
        "communityAuthoringAllowed": "true",
        "communityAccessAllowed": "true",
        "endDate": "2014/02/02"
    }
    testcycleModel.create(post_payload)
def add_components_to_product(step, stored_product, product_name):
    productModel = ProductModel()
    product = productModel.get_stored_or_store_obj(stored_product, product_name)

    product_resid, version = productModel.get_resid(product)

    for component in step.hashes:
        productModel.add_component(product_resid, version,
                                   {"name": component["name"],
                                    "description": component["description"]})
Example #11
0
def create_testcycles(step):
    testcycleModel = TestcycleModel()

    for item in step.hashes:
        # must do this or it will freak out the lettuce reporting, because
        # we delete items from this before submitting.
        testcycle = item.copy()

        # get the product id from the passed product name
        product_id = ProductModel().get_resid(testcycle["product name"])[0]

        testcycle["productId"] = product_id

        if testcycle.has_key('product name'):
            del testcycle['product name']

        testcycleModel.create(testcycle)
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 product_foo_has_environment_bar(step, product_name, haveness, envgrp_name):
    # fetch the product's resource identity
    productModel = ProductModel()
    expect_to_find = (haveness == "has")

    productModel.verify_has_environmentgroup(product_name, envgrp_name, expect_to_find)
def add_environmentgroup_to_product(step, envgrp_name, product_name):
    productModel = ProductModel()
    envgrp_id = EnvironmentgroupModel().get_resid(envgrp_name)[0]
    productModel.add_environmentgroups(product_name, envgrp_id)
def delete_product_with_name(step, stored, name):
    productModel = ProductModel()
    name = productModel.get_stored_or_store_name(stored, name)

    productModel.delete(name)
def check_product_existence(step, stored, name, existence):
    productModel = ProductModel()
    name = productModel.get_stored_or_store_name(stored, name)
    productModel.verify_existence_on_root(name, existence = existence)