示例#1
0
def test_sqlite_reading_bad_config():
    adapter = SQLiteAdapter(":memory:")
    # inject bad data (array, needs to be dict)
    # store_config does not check the input type, just uses json.dumps()
    adapter.store_config("foo_conf", [])

    with pytest.raises(ValueError,
                       match="reading config data and got non-dict result"):
        adapter.read_config("foo_conf")
示例#2
0
def test_remove_config():
    adapter = SQLiteAdapter(MEMORY_DBNAME)
    store_val = {"val1": True, "val2": None, "val3": 1.4}
    adapter.store_config("myconf", store_val)
    adapter.store_config("myconf2", store_val)
    removed = adapter.remove_config("myconf")
    assert removed
    read_val = adapter.read_config("myconf")
    assert read_val is None
    read_val = adapter.read_config("myconf2")
    assert read_val == store_val

    removed = adapter.remove_config("myconf")
    assert not removed
示例#3
0
def test_store_and_retrieve_simple_config():
    adapter = SQLiteAdapter(MEMORY_DBNAME)
    store_val = {"val1": True, "val2": None, "val3": 1.4}
    adapter.store_config("myconf", store_val)
    read_val = adapter.read_config("myconf")
    assert read_val == store_val
    assert read_val is not store_val
示例#4
0
def test_load_missing_config_data():
    adapter = SQLiteAdapter(MEMORY_DBNAME)
    assert adapter.read_config("foo") is None