def test_as_dict():
    data = {'key1': 'value1', 'sub_data': {'one': 1, 'two': 2}}
    cfg = AdvancedConfiguration(data)
    assert cfg.as_dict() == data

    cfg.lock_key('key1')
    cfg.lock_key('sub_data.one')
    locked_data = {'#key1': 'value1', 'sub_data': {'#one': 1, 'two': 2}}
    assert cfg.as_dict(keep_locks=True) == locked_data
def test_lock_key():
    data1 = {'list': [1, 2], 'int': 5, 'dict': {'str': 'A sentence'}}
    cfg = AdvancedConfiguration(data1)

    cfg.lock_key('int')
    assert cfg.is_locked('int')

    cfg.lock_key('dict.str')
    assert cfg.is_locked('dict.str')
def test_lock_set():
    data1 = {'#list': [1, 2], 'int': 5, 'dict': {'#str': 'A sentence'}}
    cfg = AdvancedConfiguration(data1)

    with pytest.raises(LockError):
        cfg.set('list', [3, 4])

    cfg.lock_key('int')
    with pytest.raises(LockError):
        cfg.set('int', 1)