66:db31e73bde12
Anton Shestakov <av6@dwimlabs.net>, Sat, 25 Jun 2016 18:16:39 +0800
models: drop Check.raw field (not worth storing in the same table) Replaying checks can be done (and is easier) when storing checker output in plain files, so let's lighten up the load on the database.

next change 69:4ec316ee87e8
previous change 63:c43e088b6aed

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
errors, warnings, extra = mlo('hello.py:42:1: W123 clowntown ahoy')
assert errors == 0
assert warnings == 1
assert sorted(extra.keys()) == ['cls', 'fileline', 'filename']
assert extra['cls'] == 'warning'
assert extra['filename'] == 'hello.py'
assert extra['fileline'] == 42
errors, warnings, extra = mlo('file with spaces:007:001: [error] oops!')
assert errors == 1
assert warnings == 0
assert sorted(extra.keys()) == ['cls', 'fileline', 'filename']
assert extra['cls'] == 'error'
assert extra['filename'] == 'file with spaces'
assert extra['fileline'] == 7
errors, warnings, extra = mlo('requirements.txt:1:1: PIL is obsolete.')
assert errors == 0
assert warnings == 1
assert sorted(extra.keys()) == ['cls', 'fileline', 'filename']
assert extra['cls'] == 'warning'
assert extra['filename'] == 'requirements.txt'
assert extra['fileline'] == 1
errors, warnings, extra = mlo('ham.lua:414:90: (E101) foo is not good')
assert errors == 1
assert warnings == 0
assert sorted(extra.keys()) == ['cls', 'fileline', 'filename']
assert extra['cls'] == 'error'
assert extra['filename'] == 'ham.lua'
assert extra['fileline'] == 414
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('~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/scm/projects/hello-world')
assert result == ('example.com', 'scm', 'projects/hello-world')
result = parse_project_url('https://example.com///hello-world//')
assert result == ('example.com', None, 'hello-world')