1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-12 19:38:57 +00:00
gns3-server/tests/dynamips/test_atm_bridge.py
grossmj 5560e81f9a Change rename command to a name property setter for all Dynamips
devices. Adjust the tests and upload the new dynamips that supports the
rename command for VMs.
2014-02-05 15:45:33 -07:00

63 lines
1.7 KiB
Python

from gns3server.modules.dynamips import ATMBridge
from gns3server.modules.dynamips import NIO_Null
from gns3server.modules.dynamips import DynamipsError
import pytest
@pytest.fixture
def atm_bridge(request, hypervisor):
atm_bridge = ATMBridge(hypervisor, "ATM bridge")
request.addfinalizer(atm_bridge.delete)
return atm_bridge
def test_atm_bridge_exists(atm_bridge):
assert atm_bridge.list()
def test_rename_atm_bridge(atm_bridge):
atm_bridge.name = "new ATM bridge"
assert atm_bridge.name == "new ATM bridge"
def test_add_remove_nio(atm_bridge):
nio = NIO_Null(atm_bridge.hypervisor)
atm_bridge.add_nio(nio, 0) # add NIO on port 0
assert atm_bridge.nios
atm_bridge.remove_nio(0) # remove NIO from port 0
nio.delete()
def test_add_nio_already_allocated_port(atm_bridge):
nio = NIO_Null(atm_bridge.hypervisor)
atm_bridge.add_nio(nio, 0) # add NIO on port 0
with pytest.raises(DynamipsError):
atm_bridge.add_nio(nio, 0)
nio.delete()
def test_remove_nio_non_allocated_port(atm_bridge):
with pytest.raises(DynamipsError):
atm_bridge.remove_nio(0) # remove NIO from port 0
def test_bridge(atm_bridge):
nio1 = NIO_Null(atm_bridge.hypervisor)
atm_bridge.add_nio(nio1, 0) # add NIO on port 0 (Ethernet NIO)
nio2 = NIO_Null(atm_bridge.hypervisor)
atm_bridge.add_nio(nio1, 1) # add NIO on port 1 (ATM NIO)
atm_bridge.configure(0, 1, 10, 10) # configure Ethernet port 0 -> ATM port 1 with VC 10:10
assert atm_bridge.mapping[0] == (1, 10, 10)
atm_bridge.unconfigure()
atm_bridge.remove_nio(0)
atm_bridge.remove_nio(1)
nio1.delete()
nio2.delete()