예제 #1
0
def test_RosdepDatabase_get_view_dependencies():
    from rosdep2.model import RosdepDatabase

    data = {'a': 1}
    db = RosdepDatabase()
    
    db.set_view_data('foo', data, [], 'origin')
    assert [] == db.get_view_dependencies('foo')

    db.set_view_data('bar', data, ['foo'], 'origin')
    assert ['foo'] == db.get_view_dependencies('bar')

    db.set_view_data('baz', data, ['bar'], 'origin')
    assert ['foo', 'bar'] ==  db.get_view_dependencies('baz')

    db.set_view_data('rad', data, [], 'origin')
    db.set_view_data('fad', data, ['baz', 'rad'], 'origin')
    retval = db.get_view_dependencies('fad')
    assert set(['baz', 'rad', 'foo', 'bar']) == set(retval), retval
    assert len(retval) == 4
예제 #2
0
def test_RosdepDatabase():
    from rosdep2.model import RosdepDatabase

    db = RosdepDatabase()
    assert not db.is_loaded('foo')

    data = {'a': 1}
    db.set_view_data('foo', data, [], 'origin1')
    assert db.is_loaded('foo')    
    entry = db.get_view_data('foo')
    assert entry.rosdep_data == data
    assert entry.origin == 'origin1'
    assert entry.view_dependencies == []
    # make sure data is copy
    data['a'] = 2
    assert entry.rosdep_data != data
    
    data = {'b': 2}
    db.set_view_data('bar', data, ['foo'], 'origin2')
    assert db.is_loaded('bar')    
    entry = db.get_view_data('bar')
    assert entry.rosdep_data == data
    assert entry.origin == 'origin2'
    assert entry.view_dependencies == ['foo']

    # override entry for bar
    data = {'b': 3}
    assert db.is_loaded('bar')    
    db.set_view_data('bar', data, ['baz', 'blah'], 'origin3')
    assert db.is_loaded('bar')    
    entry = db.get_view_data('bar')
    assert entry.rosdep_data == data
    assert entry.origin == 'origin3'
    assert set(entry.view_dependencies) == set(['baz', 'blah'])