mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
4 files changed
+79
-1
No files matched your search
@@ -37,6 +37,7 @@ def test_save(controller, controller_config_path):
|
||||
data = json.load(f)
|
||||
assert data["computes"] == []
|
||||
assert data["version"] == __version__
|
||||
assert data["settings"] == {}
|
||||
|
||||
|
||||
def test_load(controller, controller_config_path, async_run):
|
||||
@@ -53,10 +54,12 @@ def test_load(controller, controller_config_path, async_run):
|
||||
"compute_id": "test1"
|
||||
}
|
||||
]
|
||||
data["settings"] = {"IOU": True}
|
||||
with open(controller_config_path, "w+") as f:
|
||||
json.dump(data, f)
|
||||
async_run(controller.load())
|
||||
assert len(controller.computes) == 1
|
||||
assert controller.settings["IOU"]
|
||||
assert controller.computes["test1"].__json__() == {
|
||||
"compute_id": "test1",
|
||||
"connected": False,
|
||||
@@ -68,6 +71,12 @@ def test_load(controller, controller_config_path, async_run):
|
||||
}
|
||||
|
||||
|
||||
def test_settings(controller):
|
||||
controller._notification = MagicMock()
|
||||
controller.settings = {"a": 1}
|
||||
controller._notification.emit.assert_called_with("settings.updated", {"a": 1})
|
||||
|
||||
|
||||
def test_load_projects(controller, projects_dir, async_run):
|
||||
controller.save()
|
||||
|
||||
@@ -270,4 +279,3 @@ def test_load_project(controller, async_run, tmpdir):
|
||||
with asyncio_patch("gns3server.controller.Controller.add_project") as mock_add_project:
|
||||
project = async_run(controller.load_project(str(tmpdir / "test.gns3")))
|
||||
assert not mock_add_project.called
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2015 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
This test suite check /version endpoint
|
||||
It's also used for unittest the HTTP implementation.
|
||||
"""
|
||||
|
||||
from gns3server.config import Config
|
||||
|
||||
|
||||
|
||||
def test_settings(http_controller):
|
||||
query = {"test": True}
|
||||
response = http_controller.post('/settings', query, example=True)
|
||||
assert response.status == 201
|
||||
response = http_controller.get('/settings', example=True)
|
||||
assert response.status == 200
|
||||
assert response.json == query
|
||||
|
||||
Reference in new issue
Block a user