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)
コード例 #2
0
def create_a_new_company_with_name(step, company_name):
    post_payload = {"name": company_name,
                    "phone": "617-417-0593",
                    "address": "31 lakeside drive",
                    "city": "Boston",
                    "zip": "01721",
                    "url": "http//www.utest.com",
                    "countryId": 123
                    }

    companyModel = CompanyModel()
    companyModel.create(post_payload)
コード例 #3
0
def create_companies(step):
    companyModel = CompanyModel()
    for item in step.hashes:
        company = item.copy()
        # persist the last one we make.  Sometimes we will only make one.
        world.names["company"] = company["name"]

        # get the product id from the passed product name
        #country_id = get_country_resid(company["country name"])
        country_id = 123
        company["countryId"] = country_id
        del company["country name"]

        companyModel.create(company)
コード例 #4
0
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)
コード例 #5
0
def create_tag_with_name(step, stored, tag):
    tagModel = TagModel()
    tag = tagModel.get_stored_or_store_name(stored, tag)

    post_payload = {
        "companyId": CompanyModel().get_seed_resid()[0],
        "name": tag
    }
    tagModel.create(post_payload)
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)
コード例 #7
0
def update_user_with_name(step, stored, name):
    name = get_stored_or_store_name("user", stored, name)

    user_id, version = UserModel().get_resid(name)

    new_values = step.hashes[0].copy()
    company_id = CompanyModel().get_resid(new_values["company name"])
    new_values["companyId"] = company_id
    del new_values["company name"]
    new_values["originalVersionId"] = version

    do_put(UserModel().root_path + "/" + str(user_id), new_values)
def create_environmentgroup_with_name(step, stored, name, type_name):
    model = EnvironmentgroupModel()
    name = model.get_stored_or_store_name(stored, name)

    type_resid = EnvironmenttypeModel().get_resid(type_name)[0]

    post_payload = {
                    "name": name,
                    "description": "oh, this old thing...",
                    "companyId": CompanyModel().get_seed_resid()[0],
                    "environmentTypeId": type_resid
                    }
    model.create(post_payload)
def create_environmentgroups(step):
    model = EnvironmentgroupModel()

    for envgrp in step.hashes:

        type_resid = EnvironmenttypeModel().get_resid(envgrp["environmenttype name"],)[0]

        post_payload = {
                        "name": envgrp["name"],
                        "description": envgrp["description"],
                        "companyId": CompanyModel().get_seed_resid()[0],
                        "environmentTypeId": type_resid
                        }
        model.create(post_payload)
def create_environmenttype_with_name(step, group, stored, name):
    '''
        This creates an environmenttype that applies to an environmentGroup object
    '''
    groupType = (group.strip() == "group environmenttype")
    envtypeModel = EnvironmenttypeModel()
    name = envtypeModel.get_stored_or_store_name(stored, name)

    post_payload = {
                    "name": name,
                    "groupType": groupType,
                    "companyId": CompanyModel().get_seed_resid()[0]
                    }
    envtypeModel.create(post_payload)
def create_environment_with_name(step, stored, name, type_name):
    '''
        This creates an environmenttype that applies to an environment object
    '''
    model = EnvironmentModel()
    name = model.get_stored_or_store_name(stored, name)

    type_resid = EnvironmenttypeModel().get_resid(type_name)[0]

    params = {
              "name": name,
              "companyId": CompanyModel().get_seed_resid()[0],
              "environmentTypeId": type_resid
              }

    model.create(params)
コード例 #12
0
def create_user_from_name(name):
    '''
        Create a user based on just the user name and seed data
    '''
    names = name.split()
    fname = names[0]
    lname = names[1]
    user_obj = {
        "firstName": fname,
        "lastName": lname,
        "email": fname + lname + "@mozilla.com",
        "screenName": fname + lname,
        "password": get_user_password(name),
        "companyId": CompanyModel().get_seed_resid()[0],
    }
    create_user_from_obj(user_obj)
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)
コード例 #14
0
def delete_company_with_name(step, stored, name):
    companyModel = CompanyModel()
    name = companyModel.get_stored_or_store_name(stored, name)
    companyModel.delete(name)