1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Fix version test

This commit is contained in:
Julien Duponchelle 2015-03-16 10:18:37 +01:00
parent 21587fda5a
commit 3a6a04b8e5
2 changed files with 14 additions and 4 deletions

View File

@ -32,7 +32,7 @@ class VersionHandler:
def version(request, response): def version(request, response):
config = Config.instance() config = Config.instance()
local_server =config.get_section_config("Server").getboolean("local", False) local_server = config.get_section_config("Server").getboolean("local", False)
response.json({"version": __version__, "local": local_server}) response.json({"version": __version__, "local": local_server})
@classmethod @classmethod

View File

@ -20,13 +20,23 @@ This test suite check /version endpoint
It's also used for unittest the HTTP implementation. It's also used for unittest the HTTP implementation.
""" """
from unittest.mock import patch, MagicMock
from configparser import ConfigParser
from gns3server.version import __version__ from gns3server.version import __version__
def test_version_output(server): def test_version_output(server):
gns_config = MagicMock()
config = ConfigParser()
config.add_section("Server")
config.set("Server", "local", "true")
gns_config.get_section_config.return_value = config["Server"]
with patch("gns3server.config.Config.instance", return_value=gns_config):
response = server.get('/version', example=True) response = server.get('/version', example=True)
assert response.status == 200 assert response.status == 200
assert response.json == {'version': __version__} assert response.json == {'local': True, 'version': __version__}
def test_version_input(server): def test_version_input(server):