mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-22 06:07:51 +00:00
Fix tests
This commit is contained in:
parent
731d24f497
commit
1f116fc992
@ -131,16 +131,26 @@ from tests.utils import asyncio_patch
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def fake_dynamips(tmpdir):
|
def fake_dynamips(tmpdir):
|
||||||
"""Create a fake IOU image on disk"""
|
"""Create a fake Dynamips image on disk"""
|
||||||
|
|
||||||
path = str(tmpdir / "7200.bin")
|
path = str(tmpdir / "7200.bin")
|
||||||
|
with open(path, "wb+") as f:
|
||||||
|
f.write(b'\x7fELF\x01\x02\x01')
|
||||||
|
os.chmod(path, stat.S_IREAD)
|
||||||
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def fake_file(tmpdir):
|
||||||
|
"""Create a fake file disk"""
|
||||||
|
|
||||||
|
path = str(tmpdir / "7200.txt")
|
||||||
with open(path, "w+") as f:
|
with open(path, "w+") as f:
|
||||||
f.write('1')
|
f.write('1')
|
||||||
os.chmod(path, stat.S_IREAD)
|
os.chmod(path, stat.S_IREAD)
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
def test_vms(server, tmpdir, fake_dynamips, fake_file):
|
||||||
def test_vms(server, tmpdir, fake_dynamips):
|
|
||||||
|
|
||||||
with patch("gns3server.modules.Dynamips.get_images_directory", return_value=str(tmpdir), example=True):
|
with patch("gns3server.modules.Dynamips.get_images_directory", return_value=str(tmpdir), example=True):
|
||||||
response = server.get("/dynamips/vms")
|
response = server.get("/dynamips/vms")
|
||||||
|
Loading…
Reference in New Issue
Block a user