mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Fix version test
This commit is contained in:
parent
21587fda5a
commit
3a6a04b8e5
@ -32,7 +32,7 @@ class VersionHandler:
|
||||
def version(request, response):
|
||||
|
||||
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})
|
||||
|
||||
@classmethod
|
||||
|
@ -20,13 +20,23 @@ This test suite check /version endpoint
|
||||
It's also used for unittest the HTTP implementation.
|
||||
"""
|
||||
|
||||
from unittest.mock import patch, MagicMock
|
||||
from configparser import ConfigParser
|
||||
|
||||
from gns3server.version import __version__
|
||||
|
||||
|
||||
def test_version_output(server):
|
||||
response = server.get('/version', example=True)
|
||||
assert response.status == 200
|
||||
assert response.json == {'version': __version__}
|
||||
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)
|
||||
assert response.status == 200
|
||||
assert response.json == {'local': True, 'version': __version__}
|
||||
|
||||
|
||||
def test_version_input(server):
|
||||
|
Loading…
Reference in New Issue
Block a user