コード例 #1
0
ファイル: general_steps.py プロジェクト: prabhat2410/orionnew
def delete_database_in_mongo(context):
    """
    Delete database used 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.
    """
    fiware_service_header = u'Fiware-Service'
    orion_prefix = u'orion'
    database_name = orion_prefix
    props_mongo = properties_class.read_properties()[
        MONGO_ENV]  # mongo properties dict
    mongo = Mongo(host=props_mongo["MONGO_HOST"],
                  port=props_mongo["MONGO_PORT"],
                  user=props_mongo["MONGO_USER"],
                  password=props_mongo["MONGO_PASS"])
    headers = context.cb.get_headers()

    if fiware_service_header in headers:
        if headers[fiware_service_header] != EMPTY:
            if headers[fiware_service_header].find(".") < 0:
                database_name = "%s-%s" % (
                    database_name, headers[fiware_service_header].lower())
            else:
                postfix = headers[fiware_service_header].lower(
                )[0:headers[fiware_service_header].find(".")]
                database_name = "%s-%s" % (database_name, postfix)

    __logger__.debug("Deleting database \"%s\" in mongo..." % database_name)
    mongo.connect(database_name)
    mongo.drop_database()
    mongo.disconnect()
    __logger__.info("...Database \"%s\" is deleted" % database_name)
コード例 #2
0
def delete_database_in_mongo(context):
    """
    Delete database used 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.
    """
    fiware_service_header = u'Fiware-Service'
    orion_prefix = u'orion'
    database_name = orion_prefix
    props_mongo = properties_class.read_properties()[MONGO_ENV]  # mongo properties dict
    mongo = Mongo(host=props_mongo["MONGO_HOST"], port=props_mongo["MONGO_PORT"], user=props_mongo["MONGO_USER"],
              password=props_mongo["MONGO_PASS"])
    headers = context.cb.get_headers()

    if fiware_service_header in headers:
        if headers[fiware_service_header] != EMPTY:
           if headers[fiware_service_header].find(".") < 0:
               database_name = "%s-%s" % (database_name, headers[fiware_service_header].lower())
           else:
               postfix = headers[fiware_service_header].lower()[0:headers[fiware_service_header].find(".")]
               database_name = "%s-%s" % (database_name, postfix)

    __logger__.debug("Deleting database \"%s\" in mongo..." % database_name)
    mongo.connect(database_name)
    mongo.drop_database()
    mongo.disconnect()
    __logger__.info("...Database \"%s\" is deleted" % database_name)
コード例 #3
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")
コード例 #4
0
def verify_mongo_is_installed_successfully(context):
    """
    verify contextBroker is installed successfully
    :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 mongo is installed successfully...")
    mongo = Mongo(host=props_mongo["MONGO_HOST"],
                  port=props_mongo["MONGO_PORT"],
                  user=props_mongo["MONGO_USER"],
                  password=props_mongo["MONGO_PASS"],
                  version=props_mongo["MONGO_VERSION"],
                  verify_version=props_mongo["MONGO_VERIFY_VERSION"])
    mongo.connect()
    mongo.eval_version()
    mongo.disconnect()
    __logger__.info("...Verified that mongo is installed successfully")
コード例 #5
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")
コード例 #6
0
def verify_mongo_is_installed_successfully(context):
    """
    verify contextBroker is installed successfully
    :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 mongo is installed successfully...")
    mongo = Mongo(host=props_mongo["MONGO_HOST"], port=props_mongo["MONGO_PORT"], user=props_mongo["MONGO_USER"],
                  password=props_mongo["MONGO_PASS"], version=props_mongo["MONGO_VERSION"],
                  verify_version=props_mongo["MONGO_VERIFY_VERSION"])
    mongo.connect()
    mongo.eval_version()
    mongo.disconnect()
    __logger__.info("...Verified that mongo is installed successfully")
コード例 #7
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")