Download:
child 354:23e5b4d4f272
parent 352:089f36d1cb18
353:935d6fb77c31
Anton Shestakov <av6@dwimlabs.net>, Mon, 13 Apr 2020 18:59:36 +0800
tests: response.body is bytes

2 файлов изменено, 44 вставок(+), 44 удалений(-) [+]
tests/test_hooks_queue.py file | annotate | diff | comparison | revisions
tests/test_viewer.py file | annotate | diff | comparison | revisions
--- a/tests/test_hooks_queue.py Mon Apr 13 12:18:17 2020 +0800
+++ b/tests/test_hooks_queue.py Mon Apr 13 18:59:36 2020 +0800
@@ -51,7 +51,7 @@
}
response = self.post_json(self.url, data, {'X-Event-Key': 'repo:push'})
assert response.code == 200
- assert '"queued": 3' in response.body
+ assert b'"queued": 3' in response.body
def test_push_git(self):
data = {
@@ -72,7 +72,7 @@
}
response = self.post_json(self.url, data, {'X-Event-Key': 'repo:push'})
assert response.code == 200
- assert '"queued": 1' in response.body
+ assert b'"queued": 1' in response.body
class GithubHookTestCase(HookTestCase):
@@ -81,12 +81,12 @@
def test_no_event(self):
response = self.post_json(self.url, {}, {})
assert response.code == 200
- assert response.body == '{"result": "unknown event"}'
+ assert response.body == b'{"result": "unknown event"}'
def test_ping(self):
response = self.post_json(self.url, {}, {'X-GitHub-Event': 'ping'})
assert response.code == 200
- assert response.body == '{"result": "pong"}'
+ assert response.body == b'{"result": "pong"}'
def test_push(self):
data = {
@@ -98,4 +98,4 @@
}
response = self.post_json(self.url, data, {'X-GitHub-Event': 'push'})
assert response.code == 200
- assert '"queued": 1' in response.body
+ assert b'"queued": 1' in response.body
--- a/tests/test_viewer.py Mon Apr 13 12:18:17 2020 +0800
+++ b/tests/test_viewer.py Mon Apr 13 18:59:36 2020 +0800
@@ -101,35 +101,35 @@
def test_index(self):
response = self.fetch('/')
assert response.code == 200
- assert 'online linter' in response.body
- assert 'test-viewer' in response.body
- assert '1 error' in response.body
- assert '1 warning' in response.body
- assert '<a href="#">default</a>' in response.body
- assert '2016-08-20T02:38:53Z' in response.body
+ assert b'online linter' in response.body
+ assert b'test-viewer' in response.body
+ assert b'1 error' in response.body
+ assert b'1 warning' in response.body
+ assert b'<a href="#">default</a>' in response.body
+ assert b'2016-08-20T02:38:53Z' in response.body
def test_404(self):
response = self.fetch('/nobodyhere')
assert response.code == 404
- assert 'online linter' in response.body
+ assert b'online linter' in response.body
def test_project(self):
response = self.fetch('/butt.cloud/cyber/wizard-attack')
assert response.code == 404
- assert 'online linter' in response.body
+ assert b'online linter' in response.body
response = self.fetch('/example.com/alice/test-viewer')
assert response.code == 200
- assert 'Clone URL' in response.body
- assert 'status.svg' in response.body
- assert '.. image:: http' in response.body
- assert '1 error' in response.body
- assert '1 warning' in response.body
- assert '<a href="#">default</a>' in response.body
- assert ('<link rel="alternate"'
- ' href="/example.com/alice/test-viewer/atom"'
- ' type="application/atom+xml"'
- ' title="test-viewer feed">') in response.body
+ assert b'Clone URL' in response.body
+ assert b'status.svg' in response.body
+ assert b'.. image:: http' in response.body
+ assert b'1 error' in response.body
+ assert b'1 warning' in response.body
+ assert b'<a href="#">default</a>' in response.body
+ assert (b'<link rel="alternate"'
+ b' href="/example.com/alice/test-viewer/atom"'
+ b' type="application/atom+xml"'
+ b' title="test-viewer feed">') in response.body
def test_atom(self):
response = self.fetch('/example.com/alice/test-viewer/atom')
@@ -148,46 +148,46 @@
def test_check(self):
response = self.fetch('/butt.cloud/cyber/wizard-attack/latest')
assert response.code == 404
- assert 'online linter' in response.body
+ assert b'online linter' in response.body
response = self.fetch('/example.com/alice/test-viewer/latest')
assert response.code == 200
- 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
- assert ('<time datetime="2016-08-20T02:38:53Z"'
- ' title="2016-08-20 02:38:53 UTC">'
- '2016-08-20 02:38:53 UTC</time>') in response.body
- assert ('<time datetime="2016-07-19T22:23+0800"'
- ' title="2016-07-19 22:23 +0800">'
- '2016-07-19 22:23 +0800</time>') in response.body
- assert 'id="check-files-data"' in response.body
- assert 'id="check-codes-data"' in response.body
- assert '"filename": "test.py"' in response.body
- assert '"code": "E501"' in response.body
+ assert b'1 error' in response.body
+ assert b'1 warning' in response.body
+ assert b'<a href="#">default</a>' in response.body
+ assert b'<a href="#" class="filelink">test.py:20</a>' in response.body
+ assert (b'<time datetime="2016-08-20T02:38:53Z"'
+ b' title="2016-08-20 02:38:53 UTC">'
+ b'2016-08-20 02:38:53 UTC</time>') in response.body
+ assert (b'<time datetime="2016-07-19T22:23+0800"'
+ b' title="2016-07-19 22:23 +0800">'
+ b'2016-07-19 22:23 +0800</time>') in response.body
+ assert b'id="check-files-data"' in response.body
+ assert b'id="check-codes-data"' in response.body
+ assert b'"filename": "test.py"' in response.body
+ assert b'"code": "E501"' 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
+ assert b'test.py' in response.body
def test_compare(self):
base_url = '/example.com/alice/test-viewer/latest'
response = self.fetch(base_url + '/compare/latest')
assert response.code == 200
- assert 'same commit' in response.body
- assert 'Diff is empty' in response.body
+ assert b'same commit' in response.body
+ assert b'Diff is empty' in response.body
response = self.fetch(base_url + '/compare/1')
assert response.code == 200
- assert 'same commit' in response.body
- assert 'E501' in response.body
+ assert b'same commit' in response.body
+ assert b'E501' in response.body
def test_status(self):
response = self.fetch('/butt.cloud/cyber/wizard-attack/status.svg')
assert response.code == 404
- assert 'online linter' in response.body
+ assert b'online linter' in response.body
response = self.fetch('/example.com/alice/test-viewer/status.svg')
assert response.code == 200