mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Merge pull request #1467 from GNS3/symbol-themes
Support symbol themes. Ref #1466
This commit is contained in:
350 files changed
+2271
-219
No files matched your search
@@ -252,10 +252,12 @@ def test_create_base_script(node, config, compute, tmpdir, async_run):
|
||||
compute.post.assert_called_with("/projects/{}/vpcs/nodes".format(node.project.id), data=data, timeout=1200)
|
||||
|
||||
|
||||
def test_symbol(node, symbols_dir):
|
||||
def test_symbol(node, symbols_dir, controller):
|
||||
"""
|
||||
Change symbol should change the node size
|
||||
"""
|
||||
|
||||
controller.symbols.theme = "Classic"
|
||||
node.symbol = ":/symbols/dslam.svg"
|
||||
assert node.symbol == ":/symbols/dslam.svg"
|
||||
assert node.width == 50
|
||||
@@ -271,7 +273,7 @@ def test_symbol(node, symbols_dir):
|
||||
assert node.label["y"] == -40
|
||||
assert node.label["style"] == None#"font-family: TypeWriter;font-size: 10.0;font-weight: bold;fill: #000000;fill-opacity: 1.0;"
|
||||
|
||||
shutil.copy(os.path.join("gns3server", "symbols", "cloud.svg"), os.path.join(symbols_dir, "cloud2.svg"))
|
||||
shutil.copy(os.path.join("gns3server", "symbols", "classic", "cloud.svg"), os.path.join(symbols_dir, "cloud2.svg"))
|
||||
node.symbol = "cloud2.svg"
|
||||
assert node.symbol == "cloud2.svg"
|
||||
assert node.width == 159
|
||||
|
||||
@@ -30,8 +30,8 @@ def test_list(symbols_dir):
|
||||
|
||||
symbols = Symbols()
|
||||
assert {
|
||||
'symbol_id': ':/symbols/firewall.svg',
|
||||
'filename': 'firewall.svg',
|
||||
'symbol_id': ':/symbols/classic/firewall.svg',
|
||||
'filename': 'classic/firewall.svg',
|
||||
'builtin': True
|
||||
} in symbols.list()
|
||||
assert {
|
||||
@@ -42,10 +42,14 @@ def test_list(symbols_dir):
|
||||
|
||||
|
||||
def test_get_path():
|
||||
|
||||
symbols = Symbols()
|
||||
assert symbols.get_path(':/symbols/firewall.svg') == get_resource("symbols/firewall.svg")
|
||||
symbols.theme = "Classic"
|
||||
assert symbols.get_path(':/symbols/classic/firewall.svg') == get_resource("symbols/classic/firewall.svg")
|
||||
|
||||
|
||||
def test_get_size():
|
||||
|
||||
symbols = Symbols()
|
||||
assert symbols.get_size(':/symbols/firewall.svg') == (66, 45, 'svg')
|
||||
symbols.theme = "Classic"
|
||||
assert symbols.get_size(':/symbols/classic/firewall.svg') == (66, 45, 'svg')
|
||||
@@ -26,14 +26,15 @@ def test_symbols(http_controller):
|
||||
response = http_controller.get('/symbols', example=True)
|
||||
assert response.status == 200
|
||||
assert {
|
||||
'symbol_id': ':/symbols/firewall.svg',
|
||||
'filename': 'firewall.svg',
|
||||
'symbol_id': ':/symbols/classic/firewall.svg',
|
||||
'filename': 'classic/firewall.svg',
|
||||
'builtin': True
|
||||
} in response.json
|
||||
|
||||
|
||||
def test_get(http_controller):
|
||||
response = http_controller.get('/symbols/' + urllib.parse.quote(':/symbols/firewall.svg') + '/raw')
|
||||
def test_get(http_controller, controller):
|
||||
controller.symbols.theme = "Classic"
|
||||
response = http_controller.get('/symbols/' + urllib.parse.quote(':/symbols/classic/firewall.svg') + '/raw')
|
||||
assert response.status == 200
|
||||
assert response.headers['CONTENT-TYPE'] == 'image/svg+xml'
|
||||
assert response.headers['CONTENT-LENGTH'] == '9381'
|
||||
|
||||
@@ -32,11 +32,11 @@ def test_get_size():
|
||||
with open("tests/resources/gns3_icon_128x64.png", "rb") as f:
|
||||
res = get_size(f.read())
|
||||
assert res == (128, 64, "png")
|
||||
with open("gns3server/symbols/dslam.svg", "rb") as f:
|
||||
with open("gns3server/symbols/classic/dslam.svg", "rb") as f:
|
||||
res = get_size(f.read())
|
||||
assert res == (50, 53, "svg")
|
||||
# Symbol using size with cm
|
||||
with open("gns3server/symbols/cloud.svg", "rb") as f:
|
||||
with open("gns3server/symbols/classic/cloud.svg", "rb") as f:
|
||||
res = get_size(f.read())
|
||||
assert res == (159, 71, "svg")
|
||||
# Size with px
|
||||
|
||||
Reference in new issue
Block a user