1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-10-10 18:08:55 +00:00
gns3-server/tests/dynamips/test_ethernet_switch.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

88 lines
2.2 KiB
Python

from gns3server.modules.dynamips import EthernetSwitch
from gns3server.modules.dynamips import NIO_Null
from gns3server.modules.dynamips import DynamipsError
import pytest
@pytest.fixture
def ethsw(request, hypervisor):
ethsw = EthernetSwitch(hypervisor, "Ethernet switch")
request.addfinalizer(ethsw.delete)
return ethsw
def test_ethsw_exists(ethsw):
assert ethsw.list()
def test_rename_ethsw(ethsw):
ethsw.name = "new Ethernet switch"
assert ethsw.name == "new Ethernet switch"
def test_add_remove_nio(ethsw):
nio = NIO_Null(ethsw.hypervisor)
ethsw.add_nio(nio, 0) # add NIO on port 0
assert ethsw.nios
ethsw.remove_nio(0) # remove NIO from port 0
nio.delete()
def test_add_nio_already_allocated_port(ethsw):
nio = NIO_Null(ethsw.hypervisor)
ethsw.add_nio(nio, 0) # add NIO on port 0
with pytest.raises(DynamipsError):
ethsw.add_nio(nio, 0)
nio.delete()
def test_remove_nio_non_allocated_port(ethsw):
with pytest.raises(DynamipsError):
ethsw.remove_nio(0) # remove NIO from port 0
def test_set_access_port(ethsw):
nio = NIO_Null(ethsw.hypervisor)
ethsw.add_nio(nio, 0) # add NIO on port 0
ethsw.set_access_port(0, 10) # set port 0 as access in VLAN 10
assert ethsw.mapping[0] == ("access", 10)
ethsw.remove_nio(0) # remove NIO from port 0
nio.delete()
def test_set_dot1q_port(ethsw):
nio = NIO_Null(ethsw.hypervisor)
ethsw.add_nio(nio, 0) # add NIO on port 0
ethsw.set_dot1q_port(0, 1) # set port 0 as 802.1Q trunk with native VLAN 1
assert ethsw.mapping[0] == ("dot1q", 1)
ethsw.remove_nio(0) # remove NIO from port 0
nio.delete()
def test_set_qinq_port(ethsw):
nio = NIO_Null(ethsw.hypervisor)
ethsw.add_nio(nio, 0) # add NIO on port 0
ethsw.set_qinq_port(0, 100) # set port 0 as QinQ trunk with outer VLAN 100
assert ethsw.mapping[0] == ("qinq", 100)
ethsw.remove_nio(0) # remove NIO from port 0
nio.delete()
def test_get_mac_addr_table(ethsw):
assert not ethsw.get_mac_addr_table() # MAC address table should be empty
def test_clear_mac_addr_table(ethsw):
ethsw.clear_mac_addr_table()