From 961c209ab1c0a6366ff7b0dcd26b458338c6efac Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Mon, 20 Feb 2017 17:25:26 +0100 Subject: [PATCH] Fix an issue when getting size from some SVG file Fix https://github.com/GNS3/gns3-gui/issues/1866 --- gns3server/utils/picture.py | 3 +- tests/resources/firefox.svg | 420 ++++++++++++++++++++++++++++++++++++ tests/utils/test_picture.py | 4 + 3 files changed, 426 insertions(+), 1 deletion(-) create mode 100644 tests/resources/firefox.svg diff --git a/gns3server/utils/picture.py b/gns3server/utils/picture.py index 4424ad9a..0fd740d8 100644 --- a/gns3server/utils/picture.py +++ b/gns3server/utils/picture.py @@ -120,7 +120,8 @@ def _svg_convert_size(size): "pc": 15, "mm": 3.543307, "cm": 35.43307, - "in": 90 + "in": 90, + "px": 1 } if len(size) > 3: if size[-2:] in conversion_table: diff --git a/tests/resources/firefox.svg b/tests/resources/firefox.svg new file mode 100644 index 00000000..2d3178f9 --- /dev/null +++ b/tests/resources/firefox.svg @@ -0,0 +1,420 @@ + + + + diff --git a/tests/utils/test_picture.py b/tests/utils/test_picture.py index d2764c40..a592d500 100644 --- a/tests/utils/test_picture.py +++ b/tests/utils/test_picture.py @@ -39,3 +39,7 @@ def test_get_size(): with open("gns3server/symbols/cloud.svg", "rb") as f: res = get_size(f.read()) assert res == (159, 71, "svg") + # Size with px + with open("tests/resources/firefox.svg", "rb") as f: + res = get_size(f.read()) + assert res == (66, 70, "svg")