Download:
child 210:6355db5628d6
parent 208:9ff907bab29e
209:8967fb24fd78
Anton Shestakov <av6@dwimlabs.net>, Mon, 22 Aug 2016 23:05:40 +0800
tests: add sample lines to the test project in test_viewer.py

1 файлов изменено, 34 вставок(+), 2 удалений(-) [+]
tests/test_viewer.py file | annotate | diff | comparison | revisions
--- a/tests/test_viewer.py Mon Aug 22 20:38:06 2016 +0800
+++ b/tests/test_viewer.py Mon Aug 22 23:05:40 2016 +0800
@@ -2,8 +2,9 @@
from xml.etree import ElementTree
from pytest import raises
+from tornado.escape import json_encode
+from tornado.testing import AsyncHTTPTestCase
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
@@ -25,11 +26,40 @@
author='alice',
message='component: do a thing',
project=project)
+ lines = [{
+ 'text': '# C&O job started: 2016-08-20T02:38:06+00:00',
+ 'cls': 'meta'
+ }, {
+ 'text': '# C&O task: setup',
+ 'task': 'setup',
+ 'cls': 'task'
+ }, {
+ 'text': '$ ../venv2/bin/flake8 --version',
+ 'task': 'setup'
+ }, {
+ 'text': '3.0.3',
+ 'task': 'setup'
+ }, {
+ 'text': '# C&O task: checks',
+ 'task': 'checks',
+ 'cls': 'task'
+ }, {
+ 'line_number': 20,
+ 'task': 'checks',
+ 'link_start': 0,
+ 'text': 'test.py:20:80: E501 line too long (82 > 79 characters)',
+ 'filename': 'test.py',
+ 'link_end': 10,
+ 'cls': 'warning'
+ }, {
+ 'text': '# C&O job finished: 2016-08-20T02:38:53+00:00',
+ 'cls': 'meta'
+ }]
Check.create(
ordinal=Check.get_next_ordinal(project),
errors=1,
warnings=1,
- lines='[]',
+ lines=json_encode(lines),
success=True,
started=datetime.now(),
finished=datetime.now(),
@@ -88,10 +118,12 @@
assert '1 error' in response.body
assert '1 warning' in response.body
assert '<a href="#">default</a>' in response.body
+ assert '<a href="#" class="filelink">test.py:20</a>' in response.body
response = self.fetch('/example.com/alice/test-viewer/latest/raw')
assert response.code == 200
assert response.headers['Content-Type'] == 'text/plain; charset=utf-8'
+ assert 'test.py' in response.body
def test_status(self):
response = self.fetch('/butt.cloud/cyber/wizard-attack/status.svg')