mirror of
https://github.com/GNS3/gns3-server.git
synced 2024-12-19 04:47:54 +00:00
Fix an issue with old symbols paths
This commit is contained in:
parent
da5e3d0e54
commit
37f972dea1
@ -204,6 +204,10 @@ class Node:
|
|||||||
|
|
||||||
@symbol.setter
|
@symbol.setter
|
||||||
def symbol(self, val):
|
def symbol(self, val):
|
||||||
|
# No abs path, fix them (bug of 1.X)
|
||||||
|
if not val.startswith(":") and os.path.abspath(val):
|
||||||
|
val = os.path.basename(val)
|
||||||
|
|
||||||
self._symbol = val
|
self._symbol = val
|
||||||
try:
|
try:
|
||||||
self._width, self._height, filetype = self._project.controller.symbols.get_size(val)
|
self._width, self._height, filetype = self._project.controller.symbols.get_size(val)
|
||||||
|
@ -70,7 +70,12 @@ class Symbols:
|
|||||||
return directory
|
return directory
|
||||||
|
|
||||||
def get_path(self, symbol_id):
|
def get_path(self, symbol_id):
|
||||||
return self._symbols_path[symbol_id]
|
try:
|
||||||
|
return self._symbols_path[symbol_id]
|
||||||
|
# Symbol not found refresh cache
|
||||||
|
except KeyError:
|
||||||
|
self.list()
|
||||||
|
return self._symbols_path[symbol_id]
|
||||||
|
|
||||||
def get_size(self, symbol_id):
|
def get_size(self, symbol_id):
|
||||||
try:
|
try:
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import shutil
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import pytest
|
import pytest
|
||||||
import uuid
|
import uuid
|
||||||
@ -188,7 +189,7 @@ def test_create_image_missing(node, compute, project, async_run):
|
|||||||
node._upload_missing_image.called is True
|
node._upload_missing_image.called is True
|
||||||
|
|
||||||
|
|
||||||
def test_symbol(node):
|
def test_symbol(node, symbols_dir):
|
||||||
"""
|
"""
|
||||||
Change symbol should change the node size
|
Change symbol should change the node size
|
||||||
"""
|
"""
|
||||||
@ -203,11 +204,22 @@ def test_symbol(node):
|
|||||||
assert node.symbol == ":/symbols/cloud.svg"
|
assert node.symbol == ":/symbols/cloud.svg"
|
||||||
assert node.width == 159
|
assert node.width == 159
|
||||||
assert node.height == 71
|
assert node.height == 71
|
||||||
|
|
||||||
assert node.label["x"] is None
|
assert node.label["x"] is None
|
||||||
assert node.label["y"] == -40
|
assert node.label["y"] == -40
|
||||||
assert node.label["style"] == "font-size: 10;font-familly: Verdana"
|
assert node.label["style"] == "font-size: 10;font-familly: Verdana"
|
||||||
|
|
||||||
|
shutil.copy(os.path.join("gns3server", "symbols", "cloud.svg"), os.path.join(symbols_dir, "cloud2.svg"))
|
||||||
|
node.symbol = "cloud2.svg"
|
||||||
|
assert node.symbol == "cloud2.svg"
|
||||||
|
assert node.width == 159
|
||||||
|
assert node.height == 71
|
||||||
|
|
||||||
|
# No abs path, fix them (bug of 1.5)
|
||||||
|
node.symbol = "/tmp/cloud2.svg"
|
||||||
|
assert node.symbol == "cloud2.svg"
|
||||||
|
assert node.width == 159
|
||||||
|
assert node.height == 71
|
||||||
|
|
||||||
|
|
||||||
def test_label_with_default_label_font(node):
|
def test_label_with_default_label_font(node):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user