mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-24 09:18:08 +00:00
Drop tornado
This commit is contained in:
parent
f0880c4a37
commit
a06d935ef4
@ -21,26 +21,12 @@ import datetime
|
||||
import sys
|
||||
import locale
|
||||
|
||||
#TODO: importing this module also configures logging options (colors etc.)
|
||||
#see https://github.com/tornadoweb/tornado/blob/master/tornado/log.py#L208
|
||||
import tornado.options
|
||||
|
||||
from gns3server.server import Server
|
||||
from gns3server.version import __version__
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
#TODO: migrate command line options to argparse
|
||||
# command line options
|
||||
from tornado.options import define
|
||||
define("host", default="0.0.0.0", help="run on the given host/IP address", type=str)
|
||||
define("port", default=8000, help="run on the given port", type=int)
|
||||
define("version", default=False, help="show the version", type=bool)
|
||||
define("quiet", default=False, help="do not show output on stdout", type=bool)
|
||||
define("console_bind_to_any", default=True, help="bind console ports to any local IP address", type=bool)
|
||||
|
||||
|
||||
def locale_check():
|
||||
"""
|
||||
Checks if this application runs with a correct locale (i.e. supports UTF-8 encoding) and attempt to fix
|
||||
@ -86,16 +72,6 @@ def main():
|
||||
"""
|
||||
|
||||
#TODO: migrate command line options to argparse (don't forget the quiet mode).
|
||||
try:
|
||||
tornado.options.parse_command_line()
|
||||
except (tornado.options.Error, ValueError):
|
||||
tornado.options.print_help()
|
||||
raise SystemExit
|
||||
|
||||
from tornado.options import options
|
||||
if options.version:
|
||||
print(__version__)
|
||||
raise SystemExit
|
||||
|
||||
current_year = datetime.date.today().year
|
||||
|
||||
|
@ -1,40 +0,0 @@
|
||||
from tornado.testing import AsyncHTTPTestCase
|
||||
from tornado.escape import json_decode
|
||||
from gns3server.server import VersionHandler
|
||||
from gns3server.version import __version__
|
||||
import tornado.web
|
||||
|
||||
"""
|
||||
Tests for the web server version handler
|
||||
"""
|
||||
|
||||
|
||||
class TestVersionHandler(AsyncHTTPTestCase):
|
||||
|
||||
URL = "/version"
|
||||
|
||||
def get_app(self):
|
||||
|
||||
return tornado.web.Application([(self.URL, VersionHandler)])
|
||||
|
||||
def test_endpoint(self):
|
||||
"""
|
||||
Tests if the response HTTP code is 200 (success)
|
||||
"""
|
||||
|
||||
self.http_client.fetch(self.get_url(self.URL), self.stop)
|
||||
response = self.wait()
|
||||
assert response.code == 200
|
||||
|
||||
def test_received_version(self):
|
||||
"""
|
||||
Tests if the returned content type is JSON and
|
||||
if the received version is the same as the server
|
||||
"""
|
||||
|
||||
self.http_client.fetch(self.get_url(self.URL), self.stop)
|
||||
response = self.wait()
|
||||
assert response.headers['Content-Type'].startswith('application/json')
|
||||
assert response.body
|
||||
body = json_decode(response.body)
|
||||
assert body['version'] == __version__
|
Loading…
Reference in New Issue
Block a user