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 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 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)