2014-03-11 23:45:04 +02:00
|
|
|
from gns3server.modules.iou import IOUDevice
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
2014-08-08 19:54:30 +03:00
|
|
|
def no_iou():
|
|
|
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
iou_path = os.path.join(cwd, "i86bi_linux-ipbase-ms-12.4.bin")
|
|
|
|
|
|
|
|
if os.path.isfile(iou_path):
|
|
|
|
return False
|
|
|
|
else:
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
2014-03-11 23:45:04 +02:00
|
|
|
@pytest.fixture(scope="session")
|
|
|
|
def iou(request):
|
|
|
|
|
|
|
|
cwd = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
iou_path = os.path.join(cwd, "i86bi_linux-ipbase-ms-12.4.bin")
|
2014-08-08 16:32:32 +03:00
|
|
|
iou_device = IOUDevice("IOU1", iou_path, "/tmp")
|
2014-03-11 23:45:04 +02:00
|
|
|
iou_device.start()
|
|
|
|
request.addfinalizer(iou_device.delete)
|
|
|
|
return iou_device
|
|
|
|
|
|
|
|
|
2014-08-08 19:54:30 +03:00
|
|
|
@pytest.mark.skipif(no_iou(), reason="IOU Image not available")
|
2014-03-11 23:45:04 +02:00
|
|
|
def test_iou_is_started(iou):
|
|
|
|
|
|
|
|
print(iou.command())
|
|
|
|
assert iou.id == 1 # we should have only one IOU running!
|
|
|
|
assert iou.is_running()
|
|
|
|
|
|
|
|
|
2014-08-08 19:54:30 +03:00
|
|
|
@pytest.mark.skipif(no_iou(), reason="IOU Image not available")
|
2014-03-11 23:45:04 +02:00
|
|
|
def test_iou_restart(iou):
|
|
|
|
|
|
|
|
iou.stop()
|
|
|
|
assert not iou.is_running()
|
|
|
|
iou.start()
|
|
|
|
assert iou.is_running()
|