aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_legacy_api.py
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2014-09-16 14:37:36 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-09-16 14:37:36 -0500
commit58a7292fed40cfad3cb386f016505d2e0ec43ad2 (patch)
treec2b32563373feea2c824a2ed7ef6c82b82677945 /mediagoblin/tests/test_legacy_api.py
parent3a02813c7a70bb2e919101343a0680fe1aa34a81 (diff)
downloadmediagoblin-58a7292fed40cfad3cb386f016505d2e0ec43ad2.tar.lz
mediagoblin-58a7292fed40cfad3cb386f016505d2e0ec43ad2.tar.xz
mediagoblin-58a7292fed40cfad3cb386f016505d2e0ec43ad2.zip
Fix test_legacy_api.py
Or rather, reimplement one of Berker's fixes and add one of mine: - add back the http_auth_headers fix Berker wrote - decode to json when testing the response.body, since we have no idea what the order will be here
Diffstat (limited to 'mediagoblin/tests/test_legacy_api.py')
-rw-r--r--mediagoblin/tests/test_legacy_api.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/mediagoblin/tests/test_legacy_api.py b/mediagoblin/tests/test_legacy_api.py
index 4e0cbd8f..f12d9ce5 100644
--- a/mediagoblin/tests/test_legacy_api.py
+++ b/mediagoblin/tests/test_legacy_api.py
@@ -17,6 +17,7 @@
import logging
import base64
+import json
import pytest
@@ -48,10 +49,10 @@ class TestAPI(object):
return template.TEMPLATE_TEST_CONTEXT[template_name]
def http_auth_headers(self):
- return {'Authorization': 'Basic {0}'.format(
- base64.b64encode(':'.join([
+ return {'Authorization': ('Basic {0}'.format(
+ base64.b64encode((':'.join([
self.user.username,
- self.user_password])))}
+ self.user_password])).encode('ascii')).decode()))}
def do_post(self, data, test_app, **kwargs):
url = kwargs.pop('url', '/api/submit')
@@ -77,8 +78,8 @@ class TestAPI(object):
'/api/test',
headers=self.http_auth_headers())
- assert response.body == \
- '{"username": "joapi", "email": "joapi@example.com"}'
+ assert json.loads(response.body) == {
+ "username": "joapi", "email": "joapi@example.com"}
def test_2_test_submission(self, test_app):
self.login(test_app)