json.loads(request.body) => json.loads(response.body.decode()))
authorChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 16 Sep 2014 19:56:13 +0000 (14:56 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 16 Sep 2014 19:56:13 +0000 (14:56 -0500)
This fixes python 3 stuff.

This commit sponsored by James Reilly.  Thanks, James!

mediagoblin/tests/test_api.py
mediagoblin/tests/test_legacy_api.py

index 31bf50b3ffabc536d18a904fbada2cdd18483b3c..3ac213660f242d1e6dab0b381dd046c12e905ec0 100644 (file)
@@ -58,7 +58,7 @@ class TestAPI(object):
                 headers=headers
             )
 
-        return response, json.loads(response.body)
+        return response, json.loads(response.body.decode())
 
     def _upload_image(self, test_app, image):
         """ Uploads and image to MediaGoblin via pump.io API """
@@ -75,7 +75,7 @@ class TestAPI(object):
                 data,
                 headers=headers
             )
-            image = json.loads(response.body)
+            image = json.loads(response.body.decode())
 
         return response, image
 
@@ -227,7 +227,7 @@ class TestAPI(object):
                 headers={"Content-Type": "application/json"}
             )
 
-        image = json.loads(response.body)["object"]
+        image = json.loads(response.body.decode())["object"]
 
         # Check everything has been set on the media correctly
         media = MediaEntry.query.filter_by(id=image["id"]).first()
@@ -406,7 +406,7 @@ class TestAPI(object):
         uri = "/api/user/{0}/profile".format(self.user.username)
         with self.mock_oauth():
             response = test_app.get(uri)
-            profile = json.loads(response.body)
+            profile = json.loads(response.body.decode())
 
             assert response.status_code == 200
 
@@ -420,7 +420,7 @@ class TestAPI(object):
         uri = "/api/user/{0}/".format(self.user.username)
         with self.mock_oauth():
             response = test_app.get(uri)
-            user = json.loads(response.body)
+            user = json.loads(response.body.decode())
 
             assert response.status_code == 200
 
@@ -446,7 +446,7 @@ class TestAPI(object):
         uri = "/api/user/{0}/feed".format(self.active_user.username)
         with self.mock_oauth():
             response = test_app.get(uri)
-            feed = json.loads(response.body)
+            feed = json.loads(response.body.decode())
 
             assert response.status_code == 200
 
@@ -481,7 +481,7 @@ class TestAPI(object):
 
         with self.mock_oauth():
             response = test_app.get(data["object"]["links"]["self"]["href"])
-            data = json.loads(response.body)
+            data = json.loads(response.body.decode())
 
             assert response.status_code == 200
 
index f12d9ce5f2eaaa06da59dddb843f3dd45bc0f832..b3b2fcec2bb0038bfeb771ffdf761e9144526770 100644 (file)
@@ -78,7 +78,7 @@ class TestAPI(object):
             '/api/test',
             headers=self.http_auth_headers())
 
-        assert json.loads(response.body) == {
+        assert json.loads(response.body.decode()) == {
             "username": "joapi", "email": "joapi@example.com"}
 
     def test_2_test_submission(self, test_app):