コード例 #1
0
def the_product_instance_is_returned_in_the_list(step):
    instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version)
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response))
    
    #response_body = xml_to_dict(world.response.content)[PRODUCT_INSTANCE_LIST][PRODUCT_INSTANCE_RES]
    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT_INSTANCE_LIST)
    response_body = response_body
    assert_true(len(response_body) != 0)
    
    product_instance = None
    for product_ins in response_body:
        if instance_id in product_ins[PRODUCT_INSTANCE_NAME]:
            product_instance = product_ins
            break

    assert_true(product_instance is not None)
    assert_equals(product_instance[PRODUCT_INSTANCE_NAME], instance_id)
    assert_true(product_instance[PRODUCT_INSTANCE_STATUS] != "")
    assert_equals(product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], world.vm_ip)
    assert_equals(product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn)
    assert_equals(product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname)
    
    assert_equals(product_instance[PRODUCT_RELEASE][VERSION], world.product_version)
    assert_equals(product_instance[PRODUCT_RELEASE][PRODUCT][PRODUCT_NAME], world.product_name)
コード例 #2
0
    def the_product_is_instantiated(self, step):
        """
        Checks if the product is instantiated with the correct data (values from world)
        :param step: Lettuce step data
        :return: world.instance_status with the installation status
        """

        world.instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version)
        response = self.api_utils.retrieve_product_instance(headers=world.headers, vdc_id=world.tenant_id,
                                                            product_instance_id=world.instance_id)

        assert_true(response.ok, 'RESPONSE: {}'.format(response))

        response_body = response_body_to_dict(response, world.headers[ACCEPT_HEADER],
                                              xml_root_element_name=PRODUCT_INSTANCE_RES)

        assert_equals(response_body[PRODUCT_INSTANCE_NAME], world.instance_id)
        assert_true(response_body[PRODUCT_INSTANCE_STATUS] != "")
        assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn)
        assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname)

        ip_aux = "" if world.vm_ip is None else world.vm_ip
        assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], ip_aux)

        assert_equals(response_body[PRODUCT_RELEASE][VERSION], world.product_version)
        assert_equals(response_body[PRODUCT_RELEASE][PRODUCT][PRODUCT_NAME], world.product_name)

        world.instance_status = response_body[PRODUCT_INSTANCE_STATUS]
コード例 #3
0
def then_the_product_is_returned_in_the_list(step):

    assert_true(world.response.ok, world.response.content)
    assert_true(world.response.ok,
                'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response,
                                          world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCTS,
                                          is_list=True)

    for product in response_body:

        if product[PRODUCT_NAME] == world.created_product_body[PRODUCT][
                PRODUCT_NAME]:
            world.exist = True
            assert_equals(
                product[PRODUCT_DESCRIPTION],
                world.created_product_body[PRODUCT][PRODUCT_DESCRIPTION])

            if world.attributes is not None:
                assert_equals(
                    product[PRODUCT_ATTRIBUTES],
                    world.created_product_body[PRODUCT][PRODUCT_ATTRIBUTES])

            if world.metadatas is not None:
                for metadata in world.created_product_body[PRODUCT][
                        PRODUCT_METADATAS]:
                    assert_in(metadata, product[PRODUCT_METADATAS])

    assert_true(world.exist)
    world.exist = False
コード例 #4
0
def the_product_instance_is_returned_in_the_list(step):
    instance_id = generate_product_instance_id(world.vm_fqn,
                                               world.product_name,
                                               world.product_version)
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response))

    response_body = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCT_INSTANCE_LIST)
    response_body = response_body
    assert_true(len(response_body) != 0)

    product_instance = None
    for product_ins in response_body:
        if instance_id in product_ins[PRODUCT_INSTANCE_NAME]:
            product_instance = product_ins
            break

    assert_true(product_instance is not None)
    assert_equals(product_instance[PRODUCT_INSTANCE_NAME], instance_id)
    assert_true(product_instance[PRODUCT_INSTANCE_STATUS] != "")
    assert_equals(
        product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP],
        world.vm_ip)
    assert_equals(
        product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN],
        world.vm_fqn)
    assert_equals(
        product_instance[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME],
        world.vm_hostname)

    assert_equals(product_instance[PRODUCT][VERSION], world.product_version)
    assert_equals(product_instance[PRODUCT][PRODUCT_NAME], world.product_name)
コード例 #5
0
def __check_metadata_response__(metadata_to_check):
    assert_true(world.response.ok,
                'RESPONSE: {}'.format(world.response.content))
    response_model = response_body_to_dict(world.response,
                                           world.headers[ACCEPT_HEADER],
                                           xml_root_element_name=METADATA)

    assert_equals(metadata_to_check, response_model)
コード例 #6
0
def then_the_attributes_product_are_retrieved(step):

    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT_ATTRIBUTES, is_list=True)

    assert_equals(world.created_product_body[PRODUCT][PRODUCT_ATTRIBUTES], response_body)
コード例 #7
0
def the_product_with_its_release_is_in_the_list(step):
    response = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCTANDRELEASE_LIST,
        is_list=True)

    assert_true(len(response) != 0)
    check_if_product_is_in_list(response, world.product_release)
コード例 #8
0
def the_product_with_all_its_releases_is_in_the_list(step):
    response = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCTANDRELEASE_LIST,
        is_list=True)

    for release in world.product_release:
        check_if_product_is_in_list(response, release)
コード例 #9
0
def then_the_attributes_product_are_empty(step):

    assert_true(world.response.ok)
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT_ATTRIBUTES, is_list=True)

    assert_true(response_body is None or len(response_body) == 0)
コード例 #10
0
ファイル: install_product.py プロジェクト: jesuspg/fiware-sdc
def the_task_has_the_minor_error_code_group1(step, error_minor_code):

    response = api_utils.retrieve_task(headers=world.headers, vdc_id=world.tenant_id, task_id=world.task_id)
    assert_true(response.ok, 'RESPONSE: {}'.format(response.content))

    world.task_response_body = response_body_to_dict(response, world.headers[ACCEPT_HEADER], with_attributes=True,
                                                     xml_root_element_name=TASK)

    assert_equals(world.task_response_body[TASK_ERROR][TASK_ERROR_MINOR_CODE], error_minor_code)
コード例 #11
0
def then_the_product_release_list_is_received(step):

    assert_true(world.response.ok)
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT_RELEASE_LIST, is_list=True)

    assert_equals(response_body[VERSION], world.product_release)
    assert_equals(response_body[PRODUCT][PRODUCT_NAME], world.product_name)
コード例 #12
0
ファイル: steps.py プロジェクト: Fiware/cloud.SDC
def the_product_is_not_in_the_list(step):
    response = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                     xml_root_element_name=PRODUCTANDRELEASE_LIST, is_list=True)

    found = False
    if len(response) != 0:
        for product_and_release in response:
            if product_and_release[PRODUCT][PRODUCT_NAME] == world.product_name:
                found = True
                break
    assert_false(found, "Product is in the list and it shouldn't!")
コード例 #13
0
def then_the_metadatas_product_are_retrieved(step):

    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT_METADATAS, is_list=True)

    if world.metadatas is not None:
        for metadata in world.created_product_body[PRODUCT][PRODUCT_METADATAS]:
            assert_in(metadata, response_body)
        world.metadatas = None
コード例 #14
0
ファイル: install_product.py プロジェクト: Fiware/cloud.SDC
def the_product_has_the_correct_attributes_in_the_catalog(step):

    response = api_utils.retrieve_product(headers=world.headers, product_id=world.product_name)
    assert_true(response.ok, "RESPONSE: {}".format(response.content))

    response_body = response_body_to_dict(response, world.headers[ACCEPT_HEADER], xml_root_element_name=PRODUCT)
    assert_equals(response_body[PRODUCT_NAME], world.product_name)
    assert_equals(response_body[PRODUCT_DESCRIPTION], world.product_description)

    if len(world.attributes) == 1:
        world.attributes = world.attributes[0]
    assert_equals(world.attributes, response_body[PRODUCT_ATTRIBUTES])
コード例 #15
0
def then_the_attributes_product_are_retrieved(step):

    assert_true(world.response.ok,
                'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCT_ATTRIBUTES,
        is_list=True)

    assert_equals(world.created_product_body[PRODUCT][PRODUCT_ATTRIBUTES],
                  response_body)
コード例 #16
0
def then_the_attributes_product_are_empty(step):

    assert_true(world.response.ok)
    assert_true(world.response.ok,
                'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCT_ATTRIBUTES,
        is_list=True)

    assert_true(response_body is None or len(response_body) == 0)
コード例 #17
0
def the_product_instance_is_returned(step):
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT_INSTANCE)

    assert_equals(response_body[PRODUCT_INSTANCE_NAME], world.instance_id)
    assert_true(response_body[PRODUCT_INSTANCE_STATUS] != "")
    assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], world.vm_ip)
    assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn)
    assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname)

    assert_equals(response_body[PRODUCT][VERSION], world.product_version)
    assert_equals(response_body[PRODUCT][PRODUCT_NAME], world.product_name)
コード例 #18
0
def then_the_metadatas_product_are_retrieved(step):

    assert_true(world.response.ok,
                'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCT_METADATAS,
        is_list=True)

    if world.metadatas is not None:
        for metadata in world.created_product_body[PRODUCT][PRODUCT_METADATAS]:
            assert_in(metadata, response_body)
        world.metadatas = None
コード例 #19
0
def the_product_is_not_in_the_list(step):
    response = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCTANDRELEASE_LIST,
        is_list=True)

    found = False
    if len(response) != 0:
        for product_and_release in response:
            if product_and_release[PRODUCT][
                    PRODUCT_NAME] == world.product_name:
                found = True
                break
    assert_false(found, "Product is in the list and it shouldn't!")
コード例 #20
0
def the_task_has_the_minor_error_code_group1(step, error_minor_code):

    response = api_utils.retrieve_task(headers=world.headers,
                                       vdc_id=world.tenant_id,
                                       task_id=world.task_id)
    assert_true(response.ok, 'RESPONSE: {}'.format(response.content))

    world.task_response_body = response_body_to_dict(
        response,
        world.headers[ACCEPT_HEADER],
        with_attributes=True,
        xml_root_element_name=TASK)

    assert_equals(world.task_response_body[TASK_ERROR][TASK_ERROR_MINOR_CODE],
                  error_minor_code)
コード例 #21
0
def the_product_has_the_correct_attributes_in_the_catalog(step):

    response = api_utils.retrieve_product(headers=world.headers,
                                          product_id=world.product_name)
    assert_true(response.ok, 'RESPONSE: {}'.format(response.content))

    response_body = response_body_to_dict(response,
                                          world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT)
    assert_equals(response_body[PRODUCT_NAME], world.product_name)
    assert_equals(response_body[PRODUCT_DESCRIPTION],
                  world.product_description)

    if len(world.attributes) == 1:
        world.attributes = world.attributes[0]
    assert_equals(world.attributes, response_body[PRODUCT_ATTRIBUTES])
コード例 #22
0
def then_the_metadatas_product_contain_default_metadatas(step):

    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCT_METADATAS, is_list=True)

    assert_equals(len(response_body), 6)

    # Add default metadata 'tenant_id'
    metadatas_with_tenant = list(DEFAULT_METADATA[METADATA])
    metadatas_with_tenant.append({"key": "tenant_id", "value": world.tenant_id})

    # Workaround: xmldict manage Empty values as None value
    replace_none_value_metadata_to_empty_string(response_body)

    assert_equals(response_body, metadatas_with_tenant)
コード例 #23
0
ファイル: delete_node.py プロジェクト: chemaper/fiware-sdc
def the_task_is_created(step):
    """ Assertions to check if TASK is created with the expected data """
    assert_true(world.response.ok,
                'RESPONSE BODY: {}'.format(world.response.content))

    response_headers = world.response.headers
    assert_equals(response_headers[CONTENT_TYPE], world.headers[ACCEPT_HEADER],
                  'RESPONSE HEADERS: {}'.format(world.response.headers))

    response_body = response_body_to_dict(world.response,
                                          world.headers[ACCEPT_HEADER],
                                          with_attributes=True,
                                          xml_root_element_name=TASK)

    assert_in(world.node_name, response_body[DESCRIPTION])
    assert_equals(world.tenant_id, response_body[TASK_VDC])

    m = re.search('/task/(.*)$', response_body[TASK_HREF])
    world.task_id = m.group(1)
コード例 #24
0
    def the_product_installation_status_is(self, step, status):
        """
        Checks the product instalation status.
        :param step: Lettuce data
        :param status: Expected status to check
        :return:
        """

        if world.instance_status is None:
            world.instance_id = "{}_{}_{}".format(world.vm_fqn, world.product_name, world.product_version)
            response = self.api_utils.retrieve_product_instance(headers=world.headers, vdc_id=world.tenant_id,
                                                                product_instance_id=world.instance_id)
            assert_true(response.ok, 'RESPONSE: {}'.format(response))

            response_body = response_body_to_dict(response, world.headers[ACCEPT_HEADER],
                                                  xml_root_element_name=PRODUCT_INSTANCE)
            world.instance_status = response_body[PRODUCT_INSTANCE_STATUS]

        assert_equals(world.instance_status, status)
コード例 #25
0
def the_product_instance_is_returned(step):
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response))

    response_body = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCT_INSTANCE)

    assert_equals(response_body[PRODUCT_INSTANCE_NAME], world.instance_id)
    assert_true(response_body[PRODUCT_INSTANCE_STATUS] != "")
    assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP],
                  world.vm_ip)
    assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN],
                  world.vm_fqn)
    assert_equals(
        response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME],
        world.vm_hostname)

    assert_equals(response_body[PRODUCT][VERSION], world.product_version)
    assert_equals(response_body[PRODUCT][PRODUCT_NAME], world.product_name)
コード例 #26
0
ファイル: add_product.py プロジェクト: flopezag/fiware-sdc
def the_product_visibility_is_group1(step, visibility):
    world.response = api_utils.retrieve_product_list(headers=world.headers)
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCTS, is_list=True)

    exist = False
    for product in response_body:
        if product[PRODUCT_NAME] == world.product_name:
            exist = True

    if visibility == 'visible':
        assert_true(exist, "Product is not visible and it should")
    else:
        #Delete hidden product
        response = api_utils.delete_product(headers=world.headers, product_id=world.product_name)
        assert_true(response.ok, 'RESPONSE: {}'.format(response.content))

        assert_false(exist, "Product is visible and it shouldn't")
コード例 #27
0
ファイル: delete_node.py プロジェクト: Fiware/cloud.SDC
def the_task_is_created(step):
    """ Assertions to check if TASK is created with the expected data """
    assert_true(world.response.ok, "RESPONSE BODY: {}".format(world.response.content))

    response_headers = world.response.headers
    assert_equals(
        response_headers[CONTENT_TYPE],
        world.headers[ACCEPT_HEADER],
        "RESPONSE HEADERS: {}".format(world.response.headers),
    )

    response_body = response_body_to_dict(
        world.response, world.headers[ACCEPT_HEADER], with_attributes=True, xml_root_element_name=TASK
    )

    assert_in(world.node_name, response_body[DESCRIPTION])
    assert_equals(world.tenant_id, response_body[TASK_VDC])

    m = re.search("/task/(.*)$", response_body[TASK_HREF])
    world.task_id = m.group(1)
コード例 #28
0
    def the_product_is_instantiated(self, step):
        """
        Checks if the product is instantiated with the correct data (values from world)
        :param step: Lettuce step data
        :return: world.instance_status with the installation status
        """

        world.instance_id = generate_product_instance_id(world.vm_fqn, world.product_name, world.product_version)
        response = self.api_utils.retrieve_product_instance(headers=world.headers, vdc_id=world.tenant_id,
                                                            product_instance_id=world.instance_id)

        assert_true(response.ok, 'RESPONSE: {}'.format(response))

        response_body = response_body_to_dict(response, world.headers[ACCEPT_HEADER],
                                              xml_root_element_name=PRODUCT_INSTANCE)

        assert_equals(response_body[PRODUCT_INSTANCE_NAME], world.instance_id)
        assert_true(response_body[PRODUCT_INSTANCE_STATUS] != "")
        assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_FQN], world.vm_fqn)
        assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_HOSTNAME], world.vm_hostname)

        ip_aux = "" if world.vm_ip is None else world.vm_ip
        assert_equals(response_body[PRODUCT_INSTANCE_VM][PRODUCT_INSTANCE_VM_IP], ip_aux)

        assert_equals(response_body[PRODUCT][VERSION], world.product_version)
        assert_equals(response_body[PRODUCT][PRODUCT_NAME], world.product_name)

        # If the instance has been created with attributes, check it.
        if world.instance_attributes is not None:
            # Check if attributes have got type.
            # Else, add plain type before check it (default type)
            for attribute in world.instance_attributes:
                if ATTRIBUTE_TYPE not in attribute:
                    attribute.update({ATTRIBUTE_TYPE: ATTRIBUTE_TYPE_PLAIN})

            world.instance_attributes = world.instance_attributes[0] \
                if len(world.instance_attributes) == 1 else world.instance_attributes
            assert_equals(response_body[PRODUCT_INSTANCE_ATTRIBUTES], world.instance_attributes)

        world.instance_status = response_body[PRODUCT_INSTANCE_STATUS]
コード例 #29
0
    def task_is_created(step):
        """
        Checks if the task is created with the correct info
        :param step: Lettuce step
        :return: In world.task_id, the task id created
        """

        assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

        response_headers = world.response.headers
        assert_in(response_headers[CONTENT_TYPE], world.headers[ACCEPT_HEADER],
                  'RESPONSE HEADERS: {}'.format(world.response.headers))

        response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER], with_attributes=True,
                                              xml_root_element_name=TASK)

        assert_equals(response_body[TASK_STATUS], TASK_STATUS_VALUE_RUNNING)
        assert_in(world.product_name, response_body[DESCRIPTION])
        assert_in(world.vm_hostname, response_body[DESCRIPTION])
        assert_equals(world.tenant_id, response_body[TASK_VDC])

        m = re.search('/task/(.*)$', response_body[TASK_HREF])
        world.task_id = m.group(1)
コード例 #30
0
def then_the_product_is_returned_in_the_list(step):

    assert_true(world.response.ok, world.response.content)
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCTS, is_list=True)

    for product in response_body:

        if product[PRODUCT_NAME] == world.created_product_body[PRODUCT][PRODUCT_NAME]:
            world.exist = True
            assert_equals(product[PRODUCT_DESCRIPTION], world.created_product_body[PRODUCT][PRODUCT_DESCRIPTION])

            if world.attributes is not None:
                assert_equals(product[PRODUCT_ATTRIBUTES], world.created_product_body[PRODUCT][PRODUCT_ATTRIBUTES])

            if world.metadatas is not None:
                for metadata in world.created_product_body[PRODUCT][PRODUCT_METADATAS]:
                    assert_in(metadata, product[PRODUCT_METADATAS])

    assert_true(world.exist)
    world.exist = False
コード例 #31
0
ファイル: add_product.py プロジェクト: chemaper/fiware-sdc
def the_product_visibility_is_group1(step, visibility):
    world.response = api_utils.retrieve_product_list(headers=world.headers)
    assert_true(world.response.ok,
                'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(world.response,
                                          world.headers[ACCEPT_HEADER],
                                          xml_root_element_name=PRODUCTS,
                                          is_list=True)

    exist = False
    for product in response_body:
        if product[PRODUCT_NAME] == world.product_name:
            exist = True

    if visibility == 'visible':
        assert_true(exist, "Product is not visible and it should")
    else:
        #Delete hidden product
        response = api_utils.delete_product(headers=world.headers,
                                            product_id=world.product_name)
        assert_true(response.ok, 'RESPONSE: {}'.format(response.content))

        assert_false(exist, "Product is visible and it shouldn't")
コード例 #32
0
def then_the_metadatas_product_contain_default_metadatas(step):

    assert_true(world.response.ok,
                'RESPONSE: {}'.format(world.response.content))

    response_body = response_body_to_dict(
        world.response,
        world.headers[ACCEPT_HEADER],
        xml_root_element_name=PRODUCT_METADATAS,
        is_list=True)

    assert_equals(len(response_body), 6)

    # Add default metadata 'tenant_id'
    metadatas_with_tenant = list(DEFAULT_METADATA[METADATA])
    metadatas_with_tenant.append({
        "key": "tenant_id",
        "value": world.tenant_id
    })

    # Workaround: xmldict manage Empty values as None value
    replace_none_value_metadata_to_empty_string(response_body)

    assert_equals(response_body, metadatas_with_tenant)
コード例 #33
0
ファイル: steps.py プロジェクト: Fiware/cloud.SDC
def the_product_with_its_release_is_in_the_list(step):
    response = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                     xml_root_element_name=PRODUCTANDRELEASE_LIST, is_list=True)

    assert_true(len(response) != 0)
    check_if_product_is_in_list(response, world.product_release)
コード例 #34
0
ファイル: steps.py プロジェクト: jesuspg/fiware-sdc
def __check_metadata_response__(metadata_to_check):
    response_model = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER], xml_root_element_name=METADATA)
    assert_true(world.response.ok, 'RESPONSE: {}'.format(world.response.content))

    assert_equals(metadata_to_check, response_model)
コード例 #35
0
ファイル: steps.py プロジェクト: Fiware/cloud.SDC
def the_product_with_all_its_releases_is_in_the_list(step):
    response = response_body_to_dict(world.response, world.headers[ACCEPT_HEADER],
                                     xml_root_element_name=PRODUCTANDRELEASE_LIST, is_list=True)

    for release in world.product_release:
        check_if_product_is_in_list(response, release)