def given_a_created_product_with_attributes_and_name_group1(step, product_id): metadatas = create_default_metadata_or_attributes_list(2) body = dict_to_xml(default_product(name=product_id, metadata=metadatas)) response = api_utils.add_new_product(headers=world.headers, body=body) assert_true(response.ok, response.content) world.product_id = response.json()[PRODUCT_NAME]
def given_a_created_product_with_name_group1(step, product_id): body = dict_to_xml(default_product(name=product_id)) response = api_utils.add_new_product(headers=world.headers, body=body) assert_true(response.ok, response.content) print response.content world.product_id = response.json()[PRODUCT_NAME]
def a_created_product_with_name(self, step, product_name, metadatas=None): """ Creates new product in SDC if not exists, using default values. - Product parameters: * Metadata: Default values if metadatas is None * Attributes: if exist in world.attributes - list - Assertions: * Product response is OK :param step: Lettuce step :param product_name: The name of the product :param metadatas: Metadata list to be used in the new product :return: None """ response = self.api_utils.retrieve_product(headers=world.headers, product_id=product_name) if response.ok: print "WARNING: Product %s already exists. It will not be created." % product_name else: metadata_list = DEFAULT_METADATA[METADATA] if metadatas is None else metadatas if world.attributes is None: body_model = default_product(name=product_name, metadata=metadata_list) else: body_model = product_with_all_parameters(name=product_name, description='QA Test', metadata=metadata_list, attributes=world.attributes) body = body_model_to_body_request(body_model, world.headers[CONTENT_TYPE], body_model_root_element=PRODUCT) response = self.api_utils.add_new_product(headers=world.headers, body=body) assert_true(response.ok, response.content)
def given_a_created_product_with_name_group1(step, product_id, product_release): world.attributes = {} body = dict_to_xml(default_product(name=product_id)) response = api_utils.add_new_product(headers=world.headers, body=body) assert_true(response.ok, response.content) world.product_id = response.json()[PRODUCT_NAME] body = dict_to_xml(create_product_release(version=product_release)) response = api_utils.add_product_release(headers=world.headers, body=body, product_id=product_id) assert_true(response.ok, response.content)