Beispiel #1
0
def test_access_exceptions_renaming_values():
    """Test renaming values linked to an access ex.

    """
    database = TaskDatabase()
    database.create_node('root', 'node1')
    database.set_value('root/node1', 'val1', 2.0)

    database.add_access_exception('root', 'root/node1', 'val1')
    database.rename_values('root/node1', ['val1'], ['new_val'], {'val1': 1})
    assert database.get_value('root', 'new_val') == 2.0
Beispiel #2
0
def test_access_exceptions_renaming_values():
    """Test renaming values linked to an access ex.

    """
    database = TaskDatabase()
    database.create_node('root', 'node1')
    database.set_value('root/node1', 'val1', 2.0)

    database.add_access_exception('root', 'root/node1', 'val1')
    database.rename_values('root/node1', ['val1'], ['new_val'], {'val1': 1})
    assert database.get_value('root', 'new_val') == 2.0
Beispiel #3
0
def test_renaming_values():
    """Test renaming values to which no access exs is linked.

    """
    database = TaskDatabase()
    database.set_value('root', 'val1', 1)
    database.rename_values('root', ['val1'], ['new_val'])
    with raises(KeyError):
        database.get_value('root', 'val1')
    assert database.get_value('root', 'new_val') == 1

    with raises(KeyError):
        database.rename_values('root', ['val1'], ['new_val'])
Beispiel #4
0
def test_renaming_values():
    """Test renaming values to which no access exs is linked.

    """
    database = TaskDatabase()
    database.set_value('root', 'val1', 1)
    database.rename_values('root', ['val1'], ['new_val'])
    with raises(KeyError):
        database.get_value('root', 'val1')
    assert database.get_value('root', 'new_val') == 1

    with raises(KeyError):
        database.rename_values('root', ['val1'], ['new_val'])
Beispiel #5
0
def test_forbidden_operations():
    """Check that all forbidden operations does raise a RuntimeError.

    """
    database = TaskDatabase()
    database.prepare_to_run()
    with raises(RuntimeError):
        database.rename_values('root', [], [])
    with raises(RuntimeError):
        database.delete_value('root', '')
    with raises(RuntimeError):
        database.create_node('root', '')
    with raises(RuntimeError):
        database.rename_node('root', '', '')
    with raises(RuntimeError):
        database.delete_node('root', '')
Beispiel #6
0
def test_forbidden_operations():
    """Check that all forbidden operations does raise a RuntimeError.

    """
    database = TaskDatabase()
    database.prepare_to_run()
    with raises(RuntimeError):
        database.rename_values('root', [], [])
    with raises(RuntimeError):
        database.delete_value('root', '')
    with raises(RuntimeError):
        database.create_node('root', '')
    with raises(RuntimeError):
        database.rename_node('root', '', '')
    with raises(RuntimeError):
        database.delete_node('root', '')