1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-30 20:28:08 +00:00
gns3-server/tests/test_version_handler.py
2013-12-05 21:39:27 -07:00

41 lines
1.1 KiB
Python

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__