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:
parent
21587fda5a
commit
3a6a04b8e5
@ -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
|
||||||
|
@ -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):
|
||||||
|
Loading…
Reference in New Issue
Block a user