144:e9e0737e1b6e
Anton Shestakov <av6@dwimlabs.net>, Sun, 17 Jul 2016 05:10:35 +0800
utils: a small module for shared functions, the first of them is rel()

next change 165:7d1baf2f0b87
previous change 128:a93fdb7416f0

tests/test_viewer.py

Permissions: -rw-r--r--

Other formats: Feeds:
from pytest import raises
from tornado.web import HTTPError
from tornado.testing import AsyncHTTPTestCase
from candolint.handlers import get_project_or_404
from candolint.models import database, Project
from viewer import CandolintViewer
def setup_module():
with database.transaction():
Project.create(
url='https://example.com/alice/test-viewer',
domain='example.com',
user='alice',
name='test-viewer')
def test_get_project_or_404():
with raises(HTTPError) as error:
get_project_or_404('butt.cloud', 'cyber', 'wizard-attack')
assert error.value.status_code == 404
project = get_project_or_404('example.com', 'alice', 'test-viewer')
assert project.id is not None
assert project.url == 'https://example.com/alice/test-viewer'
class ViewerTestCase(AsyncHTTPTestCase):
def get_app(self):
return CandolintViewer()
def test_index(self):
response = self.fetch('/')
assert response.code == 200
assert 'online linter' in response.body
def test_404(self):
response = self.fetch('/nobodyhere')
assert response.code == 404
assert 'online linter' in response.body