gns3-server/tests/vpcs/test_vpcs_device.py

34 lines
802 B
Python
Raw Normal View History

2014-05-06 16:42:38 +00:00
from gns3server.modules.vpcs import VPCSDevice
2014-05-06 15:06:25 +00:00
import os
import pytest
@pytest.fixture(scope="session")
2014-05-06 16:42:38 +00:00
def vpcs(request):
2014-05-06 15:06:25 +00:00
if os.path.isfile("/usr/bin/vpcs"):
vpcs_path = "/usr/bin/vpcs"
else:
cwd = os.path.dirname(os.path.abspath(__file__))
vpcs_path = os.path.join(cwd, "vpcs")
vpcs_device = VPCSDevice("VPCS1", vpcs_path, "/tmp")
vpcs_device.port_add_nio_binding(0, 'nio_tap:tap0')
2014-05-06 16:42:38 +00:00
vpcs_device.start()
request.addfinalizer(vpcs_device.delete)
return vpcs_device
2014-05-06 15:06:25 +00:00
2014-05-06 16:42:38 +00:00
def test_vpcs_is_started(vpcs):
2014-05-06 15:06:25 +00:00
2014-05-06 16:42:38 +00:00
print(vpcs.command())
assert vpcs.id == 1 # we should have only one VPCS running!
assert vpcs.is_running()
2014-05-06 15:06:25 +00:00
2014-05-06 16:42:38 +00:00
def test_vpcs_restart(vpcs):
2014-05-06 15:06:25 +00:00
2014-05-06 16:42:38 +00:00
vpcs.stop()
assert not vpcs.is_running()
vpcs.start()
assert vpcs.is_running()