示例#1
0
def test_web_on_loaded_with_callable():
    conf = WebConfiguration({
        'web': {
            'on_loaded': "assert app(self) == 'ok'",
        },
    })
    log = []
    conf.on_web_loaded(lambda self: log.append(self) or 'ok')
    assert log == [conf]
示例#2
0
def test_web_debug():
    conf = WebConfiguration({'web': {'debug': True}})
    assert conf.web_debug
    conf2 = WebConfiguration({'web': {'debug': False}})
    assert not conf2.web_debug
    conf3 = WebConfiguration({'web': {}})
    assert not conf3.web_debug
    conf4 = WebConfiguration({})
    assert not conf4.web_debug
示例#3
0
def test_web_on_loaded_hooks_list():
    conf = WebConfiguration({
        'web': {
            'on_loaded': [__name__ + ':' + sample_hook.__name__],
        },
    })
    app = Flask(__name__)
    conf.on_web_loaded(app)
    assert app.name == 'ok'
示例#4
0
def test_web_on_loaded():
    conf = WebConfiguration({
        'web': {
            'on_loaded': "assert app(self) == 'ok'",
        },
    })
    log = []
    conf.on_web_loaded(lambda self: log.append(self) or 'ok')
    assert log == [conf]
示例#5
0
def test_web_on_loaded():
    conf = WebConfiguration({
        'web': {
            'on_loaded':
            "assert app.name == '{}'\n"
            "app.name = 'ok'".format(__name__),
        },
    })
    app = Flask(__name__)
    conf.on_web_loaded(app)
    assert app.name == 'ok'
示例#6
0
def test_web_config():
    conf = WebConfiguration({
        'web': {
            'debug': True,
            'testing': True,
            'secret_key': 'asdf',
        },
    })
    assert conf.web_config['DEBUG']
    assert conf.web_config['TESTING']
    assert conf.web_config['SECRET_KEY'] == 'asdf'