Exemplo n.º 1
0
def verify_error_message(context):
    """
    verify error response
    :param context: parameters to evaluate
    """
    global cb, resp
    __logger__.debug("Verifying error message ...")
    ngsi = NGSI()
    ngsi.verify_error_response(context, resp)
    __logger__.info("...Verified that error message is the expected")
Exemplo n.º 2
0
def verify_that_the_attribute_is_deleted_into_mongo(context):
    """
    verify that the attribute is deleted into mongo
    """
    props_mongo = properties_class.read_properties()[MONGO_ENV]  # mongo properties dict
    __logger__.debug("Verifying if the atribute is deleted...")
    mongo = Mongo(host=props_mongo["MONGO_HOST"], port=props_mongo["MONGO_PORT"], user=props_mongo["MONGO_USER"],
                  password=props_mongo["MONGO_PASS"])
    ngsi = NGSI()
    ngsi.verify_attribute_is_deleted(mongo, context.cb.get_entity_context(), context.cb.get_headers())
    __logger__.info("...verified that the attribute is deleted")
Exemplo n.º 3
0
def verify_that_the_attribute_by_id_is_returned(context):
    """
    verify that the attribute by ID is returned
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug("Verifying an attribute by ID returned from a request...")
    entities_context = context.cb.get_entity_context()
    attribute_name_to_request = context.cb.get_attribute_name_to_request()
    ngsi = NGSI()
    ngsi.verify_an_attribute_by_id(entities_context, context.resp, attribute_name_to_request)
    __logger__.info("...Verified an attribute by ID returned from a request...")
Exemplo n.º 4
0
def verify_get_all_entities(context):
    """
    verify get all entities
    """
    global cb, resp
    __logger__.debug("Verifying all entities are returned in get request...")
    queries_parameters = cb.get_entities_parameters()
    entities_context = cb.get_entity_context()
    ngsi = NGSI()
    ngsi.verify_get_all_entities(queries_parameters, entities_context, resp)
    __logger__.info("...Verified all entities are returned in get request...")
Exemplo n.º 5
0
def verify_that_entities_are_not_sorted_by_attributes(context):
    """
    verify that entities are not sorted by attributes
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug(
        "Verifying that entities are  not sorted by attributes...")
    queries_parameters = context.cb.get_entities_parameters()
    ngsi = NGSI()
    ngsi.verify_that_entities_are_sorted_by_some_attributes(
        queries_parameters, context.entities_accumulate, context.resp, False)
    __logger__.debug("Verified that entities are not sorted by attributes...")
Exemplo n.º 6
0
def verify_http_response_in_raw_mode_witn_type(context, field_type):
    """
    verify http response in raw mode and type in attribute value from http response
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    :param field_type: field type (bool | int | float | list | dict | str | NoneType)
    """
    global cb, resp
    __logger__.debug("Verifying http response in raw mode from http response...")
    entities_context = context.cb.get_entity_context()
    ngsi = NGSI()
    ngsi.verify_entity_raw_mode_http_response(entities_context, context.resp, field_type)
    __logger__.info("...Verified http response in raw mode from http response...")
Exemplo n.º 7
0
def verify_headers_in_response(context):
    """
    verify headers in response
    Ex:
      | parameter      | value      |
      | x-total-counts | <entities> |
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug("Verifying headers in response...")
    ngsi = NGSI()
    ngsi.verify_headers_response(context)
    __logger__.info("...Verified headers in response")
Exemplo n.º 8
0
def verify_that_the_attribute_by_ID_is_returned(context):
    """
    verify that the attribute by ID is returned
    """
    global cb, resp
    __logger__.debug("Verifying an attribute by ID returned from a request...")
    entities_context = cb.get_entity_context()
    attribute_name_to_request = cb.get_attribute_name_to_request()
    ngsi = NGSI()
    ngsi.verify_an_attribute_by_id(entities_context, resp,
                                   attribute_name_to_request)
    __logger__.info(
        "...Verified an attribute by ID returned from a request...")
Exemplo n.º 9
0
def verify_that_the_entity_by_ID_is_returned(context):
    """
    verify that the entity by ID is returned
    """
    global cb, resp
    __logger__.debug("Verifying an entity by ID returned from a request...")
    queries_parameters = cb.get_entities_parameters()
    entities_context = cb.get_entity_context()
    entity_id_to_request = cb.get_entity_id_to_request()
    ngsi = NGSI()
    ngsi.verify_an_entity_by_id(queries_parameters, entities_context, resp,
                                entity_id_to_request)
    __logger__.info("...Verified an entity by ID returned from a request...")
Exemplo n.º 10
0
def verify_error_message(context):
    """
    verify error response
    :param context: parameters to evaluate
    """
    global cb, resp_list
    __logger__.debug("Verifying error message in several entities...")
    entities_context = cb.get_entity_context()
    ngsi = NGSI()
    for i in range(int(entities_context["entities_number"])):
        ngsi.verify_error_response(context, resp_list[i])
    __logger__.info(
        "...Verified that error message is the expected in all entities ")
Exemplo n.º 11
0
def verify_that_an_entity_is_updated_in_mongo(context):
    """
    verify that an entity is updated in mongo
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug(" >> verifying that an entity is updating in mongo")
    mongo = Mongo(host=props_mongo["MONGO_HOST"],
                  port=props_mongo["MONGO_PORT"],
                  user=props_mongo["MONGO_USER"],
                  password=props_mongo["MONGO_PASS"])
    ngsi = NGSI()
    ngsi.verify_entity_updated_in_mongo(mongo, context.cb.get_entity_context(),
                                        context.cb.get_headers())
    __logger__.info(" >> verified that an entity is updated in mongo")
Exemplo n.º 12
0
def entities_are_not_stored_in_mongo(context):
    """
    verify that entities are not stored in mongo
    """
    global cb
    properties_class = Properties()
    props_mongo = properties_class.read_properties()[
        "mongo_env"]  # mongo properties dict
    __logger__.debug(" >> verifying entities are not stored in mongo")
    m = Mongo(host=props_mongo["MONGO_HOST"],
              port=props_mongo["MONGO_PORT"],
              user=props_mongo["MONGO_USER"],
              password=props_mongo["MONGO_PASS"])
    ngsi = NGSI()
    ngsi.verify_entities_stored_in_mongo(m, cb.get_entity_context(),
                                         cb.get_headers(), False)
    __logger__.info(" >> verified entities are not stored in mongo")
Exemplo n.º 13
0
def verify_the_notification_in_a_given_format(context, notif_format):
    """
    verify the notification in a given format
    :param notif_format: format expected (normalized | keyValues | values | legacy)
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug("verify the notification in \"%s\" format..." %
                     notif_format)
    entity_context = context.cb.get_entity_context()
    subsc_context = context.cb.get_subscription_context()
    payload = context.resp.text
    headers = context.resp.headers
    ngsi = NGSI()
    ngsi.verify_notification(notif_format, payload, headers, entity_context,
                             subsc_context)
    __logger__.debug("...verified the notification in \"%s\" format" %
                     notif_format)
Exemplo n.º 14
0
def verify_metadata_in_notification(context, metadata_flags="*"):
    """
    verify metadata in notification
    :param metadata_flags: metadata notified
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug(
        "verifying metadata in the notification (custom user or special)...")
    entity_context = context.cb.get_entity_context()
    subsc_context = context.cb.get_subscription_context()
    action_type = context.cb.get_action_type()
    previous_value = context.cb.get_previous_value()
    payload = context.resp.text
    ngsi = NGSI()
    ngsi.verify_metadata_notification(metadata_flags, payload, entity_context,
                                      subsc_context, action_type,
                                      previous_value)
    __logger__.info("...verified metadata in the notification")
Exemplo n.º 15
0
def verify_that_attributes_in_an_entity_by_id_are_returned(context):
    """
    verify that attributes in an entity by ID are returned
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug(
        "Verifying that attributes in an entity by ID are returned from a request..."
    )
    queries_parameters = context.cb.get_entities_parameters()
    entities_context = context.cb.get_entity_context()
    entity_id_to_request = context.cb.get_entity_id_to_request()
    ngsi = NGSI()
    ngsi.verify_an_entity_by_id(queries_parameters,
                                entities_context,
                                context.resp,
                                entity_id_to_request,
                                attrs=True)
    __logger__.info(
        "...Verified that attributes in an entity by ID are returned from a request..."
    )
Exemplo n.º 16
0
def check_in_log_label_and_text(context, label, text):
    """
    Verify in log file if a label with a message exists
    :param step:
    :param label: label to find
    :param text: text to find (begin since the end)
    """
    __logger__.debug(
        "Looking for in log the \"%s\" label and the \"%s\" text..." %
        (label, text))
    props_cb_env = properties_class.read_properties()[CONTEXT_BROKER_ENV]
    remote_log = Remote_Log(file="%s/contextBroker.log" %
                            props_cb_env["CB_LOG_FILE"],
                            fabric=context.my_fab)
    line = remote_log.find_line(label, text)
    assert line != None, " ERROR - the \"%s\" label and the \"%s\" text do not exist in the log" % (
        label, text)
    __logger__.info("log line: \n%s" % line)
    ngsi = NGSI()
    ngsi.verify_log(context, line)
    __logger__.info("...confirmed traces in log")
Exemplo n.º 17
0
def verify_the_custom_notification(context):
    """
    verify the custom notification
    :param context: It’s a clever place where you and behave can store information to share around. It runs at three levels, automatically managed by behave.
    """
    __logger__.debug(
        "verifying the notification received with custom template...")

    __logger__.debug("notification received")
    __logger__.debug("headers: \n   %s" % context.resp.headers)
    __logger__.debug("payload: \n   %s" % context.resp.text)

    entity_context = context.cb.get_entity_context()
    subsc_context = context.cb.get_subscription_context()
    payload = context.resp.text
    headers = context.resp.headers
    ngsi = NGSI()
    ngsi.verify_custom_notification(payload, headers, entity_context,
                                    subsc_context)
    __logger__.info(
        "...verified the notification received with custom template")