Anton Shestakov <av6@dwimlabs.net>, Tue, 19 Jul 2016 22:22:48 +0800
tests: add sample change and check to viewer tests
tests/test_viewer.py
Permissions: -rw-r--r--
from datetime import datetime 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, Change, Check from viewer import CandolintViewer with database.transaction(): project = Project.create( url='https://example.com/alice/test-viewer', node='92cfceb39d57d914ed8b14d0e37643de0797ae56', date='2016-07-19 22:23 +0800', message='component: do a thing', ordinal=Check.get_next_ordinal(project), 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): response = self.fetch('/') assert response.code == 200 assert 'online linter' in response.body assert '1 error' in response.body assert '1 warning' in response.body response = self.fetch('/nobodyhere') assert response.code == 404 assert 'online linter' in response.body