Exemplo n.º 1
0
def verify_that_attribute_types_are_returned_in_response(context, types):
    """
    verify that entity types are returned in 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.
    """
    __logger__.debug("Verifying that entities types are returned from a request...")
    ngsi = NGSI()
    ngsi.verify_entity_types(types, context.resp)
    __logger__.info("...Verified that entities types are returned from a request...")
def verify_error_message(context):
    """
    verify error response
    :param context: parameters to evaluate. 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 error message ...")
    ngsi = NGSI()
    ngsi.verify_error_response(context, context.resp)
    __logger__.info("...Verified that error message is the expected")
Exemplo n.º 3
0
def verify_that_attribute_types_are_returned_in_response(context):
    """
    verify that attributes types are returned in response based on the info in the recorder
    :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 attribute types are returned from a request...")
    queries_parameters = context.cb.get_entities_parameters()
    ngsi = NGSI()
    ngsi.verify_attributes_types_with_entity_types(queries_parameters, context.entities_accumulate, context.resp)
    __logger__.info("...Verified that attribute types are returned from a request...")
Exemplo n.º 4
0
def verify_that_the_attribute_is_deleted_into_mongo(context):
    """
    verify that the attribute is deleted into mongo
    """
    __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.º 5
0
def verify_get_all_entities(context):
    """
    verify get all 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 all entities are returned in get request...")
    queries_parameters = context.cb.get_entities_parameters()
    ngsi = NGSI()
    ngsi.verify_get_all_entities(queries_parameters, context.entities_accumulate, context.resp)
    __logger__.info("...Verified all entities are returned in get request...")
Exemplo n.º 6
0
def verify_admin_error(context, error):
    """
    verify admin error message
    :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 error: error message expected
    """
    __logger__.debug("Verifying the admin error message: %s..." % error)
    ngsi = NGSI()
    ngsi.verify_admin_error(context, error)
    __logger__.info("...Verified that the admin error message is the expected")
Exemplo n.º 7
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.º 8
0
def verify_that_the_attribute_value_by_id_is_returned(context):
    """
    verify that the attribute value 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 value by ID returned from a request...")
    entities_context = context.cb.get_entity_context()
    ngsi = NGSI()
    ngsi.verify_an_attribute_value_by_id(entities_context, context.resp)
    __logger__.info("...Verified the attribute value by ID returned from a request...")
Exemplo n.º 9
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.º 10
0
def verify_if_the_log_level_is_the_expected(context, level):
    """
    verify if the log level is the expected

    :param level: log level expected
    :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 if the log level \"%s\" is the expected in response..." % level)
    ngsi = NGSI()
    ngsi.verify_log_level(context, level)
    __logger__.info("...Verified log level in response")
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")
def verify_error_message(context):
    """
    verify error response
    :param context: parameters to evaluate. 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 error message in several entities...")
    entities_context = context.cb.get_entity_context()
    ngsi = NGSI()
    for i in range(int(entities_context["entities_number"])):
        ngsi.verify_error_response(context, context.resp_list[i])
    __logger__.info("...Verified that error message is the expected in all entities ")
Exemplo n.º 13
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.º 14
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...")
def verify_that_the_subscription_is_stored_in_mongo(context):
    """
    verify that the subscription is stored 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.
    """
    props_mongo = properties_class.read_properties()[MONGO_ENV]  # mongo properties dict
    __logger__.debug(" >> verifying that subscription is stored 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_subscription_stored_in_mongo(mongo, context.cb.get_subscription_context(), context.cb.get_headers(), context.resp)
    __logger__.info(" >> verified that subscription is stored in mongo")
Exemplo n.º 16
0
def verify_an_attribute_by_id_in_raw_mode_from_http_response(context, field_type):
    """
    verify an attribute by ID in raw mode with 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 to verify (bool | int | float | list | dict | str | NoneType)
    """
    __logger__.debug("Verifying an attribute by ID returned in raw mode from http response...")
    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_in_raw_mode_http_response(entities_context, context.resp, attribute_name_to_request, field_type)
    __logger__.info("...Verified an attribute by ID returned in raw mode from http response...")
Exemplo n.º 17
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.º 18
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.º 19
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.º 20
0
def verify_that_the_entity_by_id_is_returned(context):
    """
    verify that the entity 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 entity by ID 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)
    __logger__.info("...Verified an entity by ID returned from a request...")
Exemplo n.º 21
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.º 22
0
def verify_that_the_entity_by_id_is_returned(context):
    """
    verify that the entity 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 entity by ID 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)
    __logger__.info("...Verified an entity by ID returned from a request...")
Exemplo n.º 23
0
def verify_headers_in_response(context):
    """
    verify headers in response
    Ex:
          | parameter          | value                |
          | Fiware-Total-Count | 5                    |
          | Location           | /v2/subscriptions/.* |
    :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.º 24
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.º 25
0
def verify_get_all_entities(context, entities_returned):
    """
    verify get all 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 %s entities are returned in get request..." %
                     entities_returned)
    queries_parameters = context.cb.get_entities_parameters()
    ngsi = NGSI()
    ngsi.verify_get_all_entities(queries_parameters,
                                 context.entities_accumulate, context.resp,
                                 entities_returned)
    __logger__.info("...Verified %s entities are returned in get request" %
                    entities_returned)
Exemplo n.º 26
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.º 27
0
def verify_that_attribute_types_are_returned_in_response(context):
    """
    verify that attributes types are returned in response based on the info in the recorder
    :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 attribute types are returned from a request...")
    queries_parameters = context.cb.get_entities_parameters()
    ngsi = NGSI()
    ngsi.verify_attributes_types_with_entity_types(queries_parameters,
                                                   context.entities_accumulate,
                                                   context.resp)
    __logger__.info(
        "...Verified that attribute types are returned from a request...")
Exemplo n.º 28
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.º 29
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.º 30
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")
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.º 32
0
def check_in_log_label_and_text(context, label, text):
    """
    Verify in log file if a label with a message exists
    :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 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 is not 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.º 33
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(),
                                     context.cb.get_entities_parameters())
    __logger__.info("...verified that the attribute is deleted")
Exemplo n.º 34
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.º 35
0
def entities_are_not_stored_in_mongo(context):
    """
    verify that entities are not stored 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.
    """
    props_mongo = properties_class.read_properties()[
        MONGO_ENV]  # mongo properties dict
    __logger__.debug(" >> verifying entities are not stored 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_entities_stored_in_mongo(mongo,
                                         context.cb.get_entity_context(),
                                         context.cb.get_headers(), False)
    __logger__.info(" >> verified entities are not stored in mongo")
Exemplo n.º 36
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.º 37
0
def verify_an_attribute_by_id_in_raw_mode_from_http_response(
        context, field_type):
    """
    verify an attribute by ID in raw mode with 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 to verify (bool | int | float | list | dict | str | NoneType)
    """
    __logger__.debug(
        "Verifying an attribute by ID returned in raw mode from http response..."
    )
    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_in_raw_mode_http_response(
        entities_context, context.resp, attribute_name_to_request, field_type)
    __logger__.info(
        "...Verified an attribute by ID returned in raw mode from http response..."
    )
Exemplo n.º 38
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.º 39
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")
Exemplo n.º 40
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.º 41
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")
Exemplo n.º 42
0
def check_in_log_label_and_text(context, label, text):
    """
    Verify in log file if a label with a message exists
    :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 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 is not 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")