mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Filter snapshots directory during the snapshot, Fixes: #1297
This commit is contained in:
1 parent
835bc24b44
commit
09c7d73ee9
2 files changed
+46
-1
No files matched your search
@@ -22,6 +22,7 @@ import pytest
|
||||
import aiohttp
|
||||
import zipfile
|
||||
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
from unittest.mock import MagicMock
|
||||
from tests.utils import AsyncioMagicMock, AsyncioBytesIO
|
||||
@@ -417,3 +418,42 @@ def test_export_images_from_vm(tmpdir, project, async_run, controller):
|
||||
with myzip.open("images/dynamips/test.image") as myfile:
|
||||
content = myfile.read()
|
||||
assert content == b"IMAGE"
|
||||
|
||||
|
||||
def test_export_with_ignoring_snapshots(tmpdir, project, async_run):
|
||||
with open(os.path.join(project.path, "test.gns3"), 'w+') as f:
|
||||
data = {
|
||||
"topology": {
|
||||
"computes": [
|
||||
{
|
||||
"compute_id": "6b7149c8-7d6e-4ca0-ab6b-daa8ab567be0",
|
||||
"host": "127.0.0.1",
|
||||
"name": "Remote 1",
|
||||
"port": 8001,
|
||||
"protocol": "http"
|
||||
}
|
||||
],
|
||||
"nodes": [
|
||||
{
|
||||
"compute_id": "6b7149c8-7d6e-4ca0-ab6b-daa8ab567be0",
|
||||
"node_type": "vpcs"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
json.dump(data, f)
|
||||
|
||||
# create snapshot directory
|
||||
snapshots_dir = os.path.join(project.path, 'snapshots')
|
||||
os.makedirs(snapshots_dir)
|
||||
Path(os.path.join(snapshots_dir, 'snap.gns3project')).touch()
|
||||
|
||||
z = async_run(export_project(project, str(tmpdir), keep_compute_id=True))
|
||||
|
||||
with open(str(tmpdir / 'zipfile.zip'), 'wb') as f:
|
||||
for data in z:
|
||||
f.write(data)
|
||||
|
||||
with zipfile.ZipFile(str(tmpdir / 'zipfile.zip')) as myzip:
|
||||
assert not os.path.join('snapshots', 'snap.gns3project') in [f.filename for f in myzip.filelist]
|
||||
|
||||
Reference in new issue
Block a user