Example #1
0
def test_jukebox_config_web_typeerror():
    with pytest.raises(TypeError):
        toml_file = '''
        [hello]
        world = 1
        '''
        jukebox_config = JukeboxConfig.from_source(toml_file)
        assert jukebox_config.web
Example #2
0
def test_jukebox_config_create_session(fx_config_source):
    jukebox_config = JukeboxConfig.from_source(fx_config_source)
    session = jukebox_config.create_session()
    assert session.bind == jukebox_config.database_engine
    other_engine = create_engine('sqlite:///test.db')
    session = jukebox_config.create_session(other_engine)
    assert session.bind != jukebox_config.database_engine
    assert session.bind == other_engine
Example #3
0
def test_jukebox_config_web():
    toml_file = '''
    [web]
    debug = true
    testing = false
    secret_key = "abc"
    '''
    jukebox_config = JukeboxConfig.from_source(toml_file)
    assert jukebox_config.web['debug']
    assert not jukebox_config.web['testing']
    assert jukebox_config.web['secret_key'] == "abc"
Example #4
0
def test_jukebox_config_database():
    toml_file = '''
    [database]
    url = "sqlite:///"
    '''
    jukebox_config = JukeboxConfig.from_source(toml_file)
    assert jukebox_config.database['url']
    toml_file = '''
    [hi]
    a = "a"
    '''
    with pytest.raises(TypeError):
        jukebox_config = JukeboxConfig.from_source(toml_file)
        assert jukebox_config.database['url']
    toml_file = '''
    [database]
    a = "sqlite:///"
    '''
    with pytest.raises(AssertionError):
        jukebox_config = JukeboxConfig.from_source(toml_file)
        assert jukebox_config.database['url']
Example #5
0
def test_jukebox_config_web_assertionerror():
    with pytest.raises(AssertionError):
        toml_file = '''
        [web]
        testing = true
        '''
        jukebox_config = JukeboxConfig.from_source(toml_file)
        print(jukebox_config.web)
    with pytest.raises(AssertionError):
        toml_file = '''
        [web]
        debug = 1
        '''
        jukebox_config = JukeboxConfig.from_source(toml_file)
        print(jukebox_config.web)
    with pytest.raises(AssertionError):
        toml_file = '''
        [web]
        secret_key = 1
        '''
        jukebox_config = JukeboxConfig.from_source(toml_file)
        print(jukebox_config.web)
Example #6
0
def test_jukebox_config_database_engine(fx_config_source):
    jukebox_config = JukeboxConfig.from_source(fx_config_source)
    assert jukebox_config.database_engine
    expect_url = jukebox_config.database['url']
    assert str(jukebox_config.database_engine.url) == expect_url
    assert jukebox_config.database_engine.echo