Suppport ~/GNS3/symbols

This commit is contained in:
Julien Duponchelle committed 2016-06-28 19:58:57 +02:00
1 parent 5b4e668eb5
commit bf154049d2
3 files changed
+48 -3

No files matched your search

+12
View File
@@ -204,6 +204,7 @@ def run_around_tests(monkeypatch, port_manager, controller, config):
port_manager._instance = port_manager
os.makedirs(os.path.join(tmppath, 'projects'))
config.set("Server", "projects_path", os.path.join(tmppath, 'projects'))
config.set("Server", "symbols_path", os.path.join(tmppath, 'symbols'))
config.set("Server", "images_path", os.path.join(tmppath, 'images'))
config.set("Server", "ubridge_path", os.path.join(tmppath, 'bin', 'ubridge'))
config.set("Server", "auth", False)
@@ -243,6 +244,17 @@ def images_dir(config):
return path
@pytest.fixture
def symbols_dir(config):
"""
Get the location of symbols
"""
path = config.get_section_config("Server").get("symbols_path")
os.makedirs(path, exist_ok=True)
print(path)
return path
@pytest.fixture
def projects_dir(config):
"""
+15 -2
View File
@@ -16,22 +16,35 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from unittest.mock import patch
from gns3server.controller.symbols import Symbols
from gns3server.utils.get_resource import get_resource
def test_list():
def test_list(symbols_dir):
print(symbols_dir)
with open(os.path.join(symbols_dir, "linux.svg"), "w+") as f:
pass
symbols = Symbols()
assert {
'symbol_id': ':/symbols/firewall.svg',
'filename': 'firewall.svg',
'builtin': True
} in symbols.list()
assert symbols
assert {
'symbol_id': 'linux.svg',
'filename': 'linux.svg',
'builtin': False
} in symbols.list()
def test_get_path():
symbols = Symbols()
assert symbols.get_path(':/symbols/firewall.svg') == get_resource("symbols/firewall.svg")