def test_switch_table_record_can_be_updated():
    table = SwitchTable()
    table.add(13, connection='wifi', next_hop=5)

    link = table[13]
    link.connection = 'ge'
    link.next_hop = 24

    assert table.as_dict() == {13: ('ge', 24)}
def test_switch_table_add_replaces_existing_record():
    table = SwitchTable()
    table.add(10, connection='eth0', next_hop=4)
    assert table.as_dict() == {10: ('eth0', 4)}
    table.add(10, connection='wifi', next_hop=9)
    assert table.as_dict() == {10: ('wifi', 9)}
def test_switch_table_as_dict_returns_read_only_dict():
    table = SwitchTable()
    with pytest.raises(TypeError):
        table.as_dict()[13] = ('illegal', 66)
def test_switch_table_add_and_as_tuple_methods():
    table = SwitchTable()
    table.add(10, connection='eth0', next_hop=4)
    table.add(22, connection='eth1', next_hop=3)
    assert table.as_dict() == {10: ('eth0', 4), 22: ('eth1', 3)}