Anton Shestakov <av6@dwimlabs.net>, Wed, 26 Oct 2016 07:33:36 +0800
viewer: add Atom feeds to projects
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