Drop tornado

This commit is contained in:
Julien Duponchelle 2015-01-19 14:21:08 +01:00
parent f0880c4a37
commit a06d935ef4
2 changed files with 0 additions and 64 deletions

View File

@ -21,26 +21,12 @@ import datetime
import sys import sys
import locale 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.server import Server
from gns3server.version import __version__ from gns3server.version import __version__
import logging import logging
log = logging.getLogger(__name__) 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(): def locale_check():
""" """
Checks if this application runs with a correct locale (i.e. supports UTF-8 encoding) and attempt to fix 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). #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 current_year = datetime.date.today().year

View File

@ -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__