Exemple #1
0
def create_app():
    # Significant performance improvement: https://github.com/MagicStack/uvloop
    asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())

    app = web.Application()
    setup_logging()
    setup_routes(app)

    setup_ontology(app)
    setup_network(app)
    setup_service_manager(app)
    setup_agent(app)

    app['name'] = 'SingularityNET Agent'

    return app
Exemple #2
0
def test_bogus_yaml_config(app):
    app = MockApp()
    setup_logging()
    settings = OntologySettings()
    original_config_file = settings.CONFIG_FILE
    log.debug("ontology original config file {0}".format(original_config_file))

    # Test missing service ontology_node_id
    log.debug(
        "ontology os.environ config file {0}".format(original_config_file))
    yaml_file = os.path.join(TEST_DIR, "ontology_test.yml")
    os.environ['SN_ONTOLOGY_CONFIG_FILE'] = yaml_file
    exception_caught = False
    try:
        ontology.setup_ontology(app)
    except RuntimeError as exception:
        exception_caught = True
        log.debug("    Expected Exception caught %s", exception)
    except:
        pass
    assert (exception_caught)

    # Test missing service name
    log.debug(
        "ontology os.environ config file {0}".format(original_config_file))
    yaml_file = os.path.join(TEST_DIR, "ontology_test_2.yml")
    os.environ['SN_ONTOLOGY_CONFIG_FILE'] = yaml_file
    exception_caught = False
    try:
        ontology.setup_ontology(app)
    except RuntimeError as exception:
        exception_caught = True
        log.debug("    Expected Exception caught %s", exception)
    except:
        pass
    assert (exception_caught)

    # Test bad section name in yaml file
    log.debug(
        "ontology os.environ config file {0}".format(original_config_file))
    yaml_file = os.path.join(TEST_DIR, "ontology_test_3.yml")
    os.environ['SN_ONTOLOGY_CONFIG_FILE'] = yaml_file
    exception_caught = False
    try:
        ontology.setup_ontology(app)
    except RuntimeError as exception:
        exception_caught = True
        log.debug("    Expected Exception caught %s", exception)
    except:
        pass
    assert (exception_caught)

    os.environ['SN_ONTOLOGY_CONFIG_FILE'] = original_config_file
def app():
    app = MockApp()
    ontology.setup_ontology(app)
    return app