Example #1
0
def test_load_server():
    config_path = os.path.join(here, 'config.toml')
    server1 = load_server(config_path, 'server_factory')
    assert isinstance(server1, montague_testapps.servers.TestServer)
    server1_testapp = server1(debug_app)
    assert server1_testapp.montague_conf['local_conf']['port'] == 42
    # server2 will be a function that does the same thing as calling server1
    # but it will be a different object due to the different entry point protocol
    server2 = load_server(config_path, 'server_runner')
    server2_testapp = server2(debug_app)
    assert server2_testapp.montague_conf['local_conf']['host'] == u'127.0.0.1'
Example #2
0
def test_load_server(fakeapp):
    config_path = os.path.join(here, 'config_files/simple_config.ini')
    server = load_server(config_path, name='server_factory')
    actual = server(fakeapp.apps.basic_app)
    assert actual.montague_conf['local_conf']['port'] == '42'
    resp = actual.get('/')
    assert b'This is basic app' == resp.body
    server = load_server(config_path, name='server_runner')
    actual = server(fakeapp.apps.basic_app2)
    assert actual.montague_conf['local_conf']['host'] == '127.0.0.1'
    resp = actual.get('/')
    assert b'This is basic app2' == resp.body
def test_load_server():
    config_path = os.path.join(here, 'config_files/simple_config.ini')
    server = load_server(config_path, name='server_factory')
    actual = server(montague_testapps.apps.basic_app)
    assert actual.montague_conf['local_conf']['port'] == '42'
    resp = actual.get('/')
    assert b'This is basic app' == resp.body
    server = load_server(config_path, name='server_runner')
    actual = server(montague_testapps.apps.basic_app2)
    assert actual.montague_conf['local_conf']['host'] == '127.0.0.1'
    resp = actual.get('/')
    assert b'This is basic app2' == resp.body
Example #4
0
def serve(ctx):
    log_config = load_logging_config(ctx.obj.config_file)
    server = load_server(ctx.obj.config_file, name=ctx.obj.server_env)
    log_config['version'] = 1
    log_config['disable_existing_loggers'] = False
    dictConfig(log_config)
    server(ctx.obj.app)
Example #5
0
 def loadserver(self, server_spec, name, relative_to, **kw):# pragma:no cover
     if server_spec.startswith('config:'):
         server_spec = server_spec[len('config:'):]
     path = os.path.join(relative_to, server_spec)
     return load_server(path, name)
Example #6
0
def serve(obj):
    server = load_server(obj.config_file, name=obj.server_env)
    server(obj.app)