306:edefddec933d
Anton Shestakov <av6@dwimlabs.net>, Sun, 24 Sep 2017 12:25:05 +0800
viewer: use subqueries to get data on index page Before, there were bare columns in the aggregate query, their values were undefined (but it somehow worked), as SQLite docs say. Good news is that now this bigger query uses (project_id, ordinal) index and is really fast.

next change 314:a3c2e221cadf
previous change 183:c90fd4f23c9e

tests/test_incoming.py

Permissions: -rw-r--r--

Other formats: Feeds:
from incoming import match_linter_output, parse_project_url
def test_match_linter_output():
mlo = match_linter_output
usual_keys = ['cls', 'filename', 'line_number', 'link_end', 'link_start']
errors, warnings, extra = mlo('hello.py:42:1: W123 clowntown ahoy')
assert errors == 0
assert warnings == 1
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'warning'
assert extra['filename'] == 'hello.py'
assert extra['line_number'] == 42
assert extra['link_start'] == 0
assert extra['link_end'] == 11
errors, warnings, extra = mlo('file with spaces:007:001: [error] oops!')
assert errors == 1
assert warnings == 0
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'error'
assert extra['filename'] == 'file with spaces'
assert extra['line_number'] == 7
assert extra['link_start'] == 0
assert extra['link_end'] == 20
errors, warnings, extra = mlo('requirements.txt:1:1: PIL is obsolete.')
assert errors == 0
assert warnings == 1
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'warning'
assert extra['filename'] == 'requirements.txt'
assert extra['line_number'] == 1
assert extra['link_start'] == 0
assert extra['link_end'] == 18
errors, warnings, extra = mlo('ham.lua:414:90: (E101) foo is not good')
assert errors == 1
assert warnings == 0
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'error'
assert extra['filename'] == 'ham.lua'
assert extra['line_number'] == 414
assert extra['link_start'] == 0
assert extra['link_end'] == 11
errors, warnings, extra = mlo('backwards.js:9091:1: not perfect (W201)')
assert errors == 0
assert warnings == 1
assert sorted(extra.keys()) == usual_keys
assert extra['cls'] == 'warning'
assert extra['filename'] == 'backwards.js'
assert extra['line_number'] == 9091
assert extra['link_start'] == 0
assert extra['link_end'] == 17
def test_parse_project_url():
result = parse_project_url('https://example.com/alice/hello-world')
assert result == ('example.com', 'alice', 'hello-world')
result = parse_project_url('https://example.com/bob/a/b/c/')
assert result == ('example.com', 'bob', 'a/b/c')
result = parse_project_url('~alice/hello-world')
assert result == ('self', '~alice', 'hello-world')
result = parse_project_url('https://code.example.com/hello-world')
assert result == ('code.example.com', None, 'hello-world')
result = parse_project_url('https://example.com///hello-world//')
assert result == ('example.com', None, 'hello-world')