From fb2dac6ef13b588c916038cc781541d8627ff654 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Wed, 28 Sep 2016 10:27:30 +0200 Subject: [PATCH] All tests pass on windows --- gns3server/utils/images.py | 4 ++-- tests/controller/test_project.py | 3 ++- tests/handlers/api/compute/test_capabilities.py | 5 ++++- tests/handlers/api/compute/test_docker.py | 1 + tests/handlers/api/controller/test_symbol.py | 7 ++++++- tests/utils/test_images.py | 8 ++++---- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/gns3server/utils/images.py b/gns3server/utils/images.py index a838a1d1d..c58a263c2 100644 --- a/gns3server/utils/images.py +++ b/gns3server/utils/images.py @@ -18,7 +18,6 @@ import os import hashlib - from ..config import Config from . import force_unix_path @@ -36,6 +35,7 @@ def scan_for_images(type): files = set() paths = [] for directory in images_directories(type): + directory = os.path.normpath(directory) for root, _, filenames in os.walk(directory): for file in filenames: path = os.path.join(root, file) @@ -46,7 +46,7 @@ def scan_for_images(type): or (file.endswith(".bin") and type == "iou") \ or (not file.endswith(".bin") and not file.endswith(".image") and type == "qemu"): files.add(file) - paths.append(path) + paths.append(force_unix_path(path)) return paths diff --git a/tests/controller/test_project.py b/tests/controller/test_project.py index 60ae678b0..46bcd6e44 100644 --- a/tests/controller/test_project.py +++ b/tests/controller/test_project.py @@ -17,6 +17,7 @@ # along with this program. If not, see . import os +import sys import uuid import json import pytest @@ -109,7 +110,7 @@ def test_init_path(tmpdir): p = Project(path=str(tmpdir), project_id=str(uuid4()), name="Test") assert p.path == str(tmpdir) - +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_changing_path_with_quote_not_allowed(tmpdir): with pytest.raises(aiohttp.web.HTTPForbidden): p = Project(project_id=str(uuid4()), name="Test") diff --git a/tests/handlers/api/compute/test_capabilities.py b/tests/handlers/api/compute/test_capabilities.py index 2280b839a..e95952912 100644 --- a/tests/handlers/api/compute/test_capabilities.py +++ b/tests/handlers/api/compute/test_capabilities.py @@ -19,12 +19,14 @@ This test suite check /version endpoint It's also used for unittest the HTTP implementation. """ +import sys +import pytest from gns3server.config import Config from gns3server.version import __version__ - +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_get(http_compute, windows_platform): """ Nat, is supported outside linux @@ -34,6 +36,7 @@ def test_get(http_compute, windows_platform): assert response.json == {'node_types': ['cloud', 'ethernet_hub', 'ethernet_switch', 'vpcs', 'virtualbox', 'dynamips', 'frame_relay_switch', 'atm_switch', 'qemu', 'vmware', 'docker', 'iou'], 'version': __version__} +@pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") def test_get_on_gns3vm(http_compute, on_gns3vm): response = http_compute.get('/capabilities', example=True) assert response.status == 200 diff --git a/tests/handlers/api/compute/test_docker.py b/tests/handlers/api/compute/test_docker.py index 003477418..6cd75a13c 100644 --- a/tests/handlers/api/compute/test_docker.py +++ b/tests/handlers/api/compute/test_docker.py @@ -26,6 +26,7 @@ from tests.utils import asyncio_patch from unittest.mock import patch, MagicMock, PropertyMock from gns3server.compute.docker import Docker +pytestmark = pytest.mark.skipif(sys.platform.startswith("win"), reason="Not supported on Windows") @pytest.fixture def base_params(): diff --git a/tests/handlers/api/controller/test_symbol.py b/tests/handlers/api/controller/test_symbol.py index 4ef0c78a7..be6e7df0a 100644 --- a/tests/handlers/api/controller/test_symbol.py +++ b/tests/handlers/api/controller/test_symbol.py @@ -16,6 +16,7 @@ # along with this program. If not, see . import os +import sys import urllib.parse from gns3server.config import Config @@ -34,7 +35,11 @@ def test_symbols(http_controller): def test_get(http_controller): response = http_controller.get('/symbols/' + urllib.parse.quote(':/symbols/firewall.svg') + '/raw') assert response.status == 200 - assert response.headers['CONTENT-LENGTH'] == '9381' + # Different carriage return + if sys.platform.startswith("win"): + assert response.headers['CONTENT-LENGTH'] == '9568' + else: + assert response.headers['CONTENT-LENGTH'] == '9381' assert response.headers['CONTENT-TYPE'] == 'image/svg+xml' assert '' in response.html diff --git a/tests/utils/test_images.py b/tests/utils/test_images.py index 5fb0fad2f..42bf6faae 100644 --- a/tests/utils/test_images.py +++ b/tests/utils/test_images.py @@ -39,9 +39,9 @@ def test_images_directories(tmpdir): # /tmp/null24564 is ignored because doesn't exists res = images_directories("qemu") - assert res[0] == str(tmpdir / "images1" / "QEMU") - assert res[1] == str(tmpdir / "images2") - assert res[2] == str(tmpdir / "images1") + assert res[0] == force_unix_path(str(tmpdir / "images1" / "QEMU")) + assert res[1] == force_unix_path(str(tmpdir / "images2")) + assert res[2] == force_unix_path(str(tmpdir / "images1")) assert len(res) == 3 @@ -115,7 +115,7 @@ def test_scan_for_images(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 scan_for_images("dynamips") == [str(path1), str(path2)]