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.
tests/test_hooks_queue.py
Permissions: -rw-r--r--
from tornado.escape import json_encode from tornado.testing import AsyncHTTPTestCase hooksmod = __import__('hooks-queue') class HookTestCase(AsyncHTTPTestCase): return hooksmod.CandolintHooks(rconn, debug=True) def post_json(self, url, data, extra_headers): headers = {'Content-Type': 'application/json'} headers.update(extra_headers) return self.fetch(url, method='POST', body=body, headers=headers) class BitbucketHookTestCase(HookTestCase): def test_invalid_payload(self): response = self.fetch(self.url, method='POST', body='invalid') assert response.code == 400 'href': 'https://bitbucket.org/example/test' 'target': {'hash': 'bar'} response = self.post_json(self.url, data, {'X-Event-Key': 'repo:push'}) assert response.code == 200 assert '"queued": 3' in response.body 'href': 'https://bitbucket.org/example/test' 'new': {'type': 'branch', 'name': 'master'} response = self.post_json(self.url, data, {'X-Event-Key': 'repo:push'}) assert response.code == 200 assert '"queued": 1' in response.body class GithubHookTestCase(HookTestCase): response = self.post_json(self.url, {}, {}) assert response.code == 200 assert response.body == '{"result": "unknown event"}' response = self.post_json(self.url, {}, {'X-GitHub-Event': 'ping'}) assert response.code == 200 assert response.body == '{"result": "pong"}' 'html_url': 'https://github.com/example/test' 'ref': 'refs/heads/master' response = self.post_json(self.url, data, {'X-GitHub-Event': 'push'}) assert response.code == 200 assert '"queued": 1' in response.body