Exemplo n.º 1
0
def clear():
    Model.destroy_model()
    Laboratory.destroy_laboratory()

    Model.create_model('test-model')
    Laboratory.create_laboratory('test-lab')

    destroy_mapping()
    create_mapping('test-map-model-to-lab')
Exemplo n.º 2
0
def test_no_dublicated_mapping():
    clear()

    m = Model.add_host('alice')
    n = Laboratory.add_device('node1')
    bind(m, n)
    bind(m, n)
    bind(n, m)
    assert len(get_mapping().bindings()) == 1
Exemplo n.º 3
0
def test_binding():
    clear()

    m = Model.add_host('alice')
    n = Laboratory.add_device('node1')
    bind(m, n)

    assert(m.bound() == n)
    assert(n.bound() == m)
    assert len(get_mapping().bindings()) == 1
Exemplo n.º 4
0
def test_mapping_by_name():
    clear()

    m = Model.add_host('alice')
    n = Laboratory.add_device('node1')

    mi = m.add_interface('eth')
    ni = n.add_interface('eth1')

    bind('alice', 'node1')
    bind('alice.eth', 'node1.eth1')

    assert(m.bound() == n)
    assert(n.bound() == m)

    assert(mi.bound() == ni)
    assert(ni.bound() == mi)