mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-20 21:33:09 +00:00
Fix some bugs on windows
This commit is contained in:
parent
3a8ca1071e
commit
be5d543f20
@ -472,7 +472,6 @@ def _convert_snapshots(topo_dir):
|
||||
for root, dirs, files in os.walk(snapshot_dir):
|
||||
for file in files:
|
||||
myzip.write(os.path.join(root, file), os.path.relpath(os.path.join(root, file), snapshot_dir), compress_type=zipfile.ZIP_DEFLATED)
|
||||
shutil.copy(snapshot_arc, "/tmp/test.zip")
|
||||
|
||||
shutil.rmtree(old_snapshots_dir)
|
||||
|
||||
|
@ -17,17 +17,17 @@
|
||||
|
||||
|
||||
import re
|
||||
import os
|
||||
import textwrap
|
||||
import posixpath
|
||||
|
||||
import pathlib
|
||||
|
||||
def force_unix_path(path):
|
||||
"""
|
||||
:param path: Path to convert
|
||||
"""
|
||||
|
||||
path = path.replace("\\", "/")
|
||||
return posixpath.normpath(path)
|
||||
p = pathlib.Path(os.path.normpath(path))
|
||||
return p.as_posix()
|
||||
|
||||
|
||||
def macaddress_to_int(mac_address):
|
||||
|
@ -136,7 +136,7 @@ def test_get_abs_image_additional_image_paths(qemu, tmpdir):
|
||||
|
||||
with patch("gns3server.config.Config.get_section_config", return_value={
|
||||
"images_path": str(tmpdir / "images1"),
|
||||
"additional_images_path": "/tmp/null24564:{}".format(tmpdir / "images2"),
|
||||
"additional_images_path": "/tmp/null24564:{}".format(str(tmpdir / "images2")),
|
||||
"local": False}):
|
||||
assert qemu.get_abs_image_path("test1.bin") == path1
|
||||
assert qemu.get_abs_image_path("test2.bin") == path2
|
||||
|
@ -77,8 +77,13 @@ def test_convert(directory, tmpdir):
|
||||
file_path = os.path.join(work_directory, directory, file)
|
||||
assert os.path.exists(file_path), "{} is missing".format(os.path.join(directory, file))
|
||||
|
||||
# For gns3project we check if size are not too much differents
|
||||
if file_path.endswith(".gns3project"):
|
||||
size = os.stat(file_path).st_size
|
||||
other_size = os.stat(os.path.join(os.path.join(root, file))).st_size
|
||||
assert size in range(other_size - 100, other_size + 100), "File {} is different".format(os.path.join(directory, file))
|
||||
# For non .gns3 file we check if the file are the same
|
||||
if not file_path.endswith(".gns3"):
|
||||
elif not file_path.endswith(".gns3"):
|
||||
assert os.stat(file_path).st_size == os.stat(os.path.join(os.path.join(root, file))).st_size, "File {} is different".format(os.path.join(directory, file))
|
||||
|
||||
# Check if we don't have unexpected file in work directory
|
||||
|
@ -15,7 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import sys
|
||||
from gns3server.utils import *
|
||||
|
||||
|
||||
@ -23,6 +23,8 @@ def test_force_unix_path():
|
||||
assert force_unix_path("a/b") == "a/b"
|
||||
assert force_unix_path("a\\b") == "a/b"
|
||||
assert force_unix_path("a\\b\\..\\c") == "a/c"
|
||||
if sys.platform.startswith("win"):
|
||||
assert force_unix_path("C:\Temp") == "C:/Temp"
|
||||
|
||||
|
||||
def test_macaddress_to_int():
|
||||
|
Loading…
Reference in New Issue
Block a user