aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/tests/test_api.py
diff options
context:
space:
mode:
authorJessica Tallon <jessica@megworld.co.uk>2014-07-12 08:42:39 +0100
committerJessica Tallon <jessica@megworld.co.uk>2014-07-22 23:13:16 +0100
commit3c8bd177b24cbc53dba9ebc8a03f83370e409c4f (patch)
tree405725bf60c102adda37616128a8f368c7d56c5e /mediagoblin/tests/test_api.py
parent51ab51921e5104f1b71402d38928651562c7134a (diff)
downloadmediagoblin-3c8bd177b24cbc53dba9ebc8a03f83370e409c4f.tar.lz
mediagoblin-3c8bd177b24cbc53dba9ebc8a03f83370e409c4f.tar.xz
mediagoblin-3c8bd177b24cbc53dba9ebc8a03f83370e409c4f.zip
Add test for API object endpoint
Diffstat (limited to 'mediagoblin/tests/test_api.py')
-rw-r--r--mediagoblin/tests/test_api.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py
index 38d4c0d5..07c34d04 100644
--- a/mediagoblin/tests/test_api.py
+++ b/mediagoblin/tests/test_api.py
@@ -178,6 +178,35 @@ class TestAPI(object):
# Assert that we've got a 403
assert "403 FORBIDDEN" in excinfo.value.message
+ def test_object_endpoint(self, test_app):
+ """ Tests that object can be looked up at endpoint """
+ # Post an image
+ response, data = self._upload_image(test_app, GOOD_JPG)
+ response, data = self._post_image_to_feed(test_app, data)
+
+ # Now lookup image to check that endpoint works.
+ image = data["object"]
+
+ assert "links" in image
+ assert "self" in image["links"]
+
+ # Get URI and strip testing host off
+ object_uri = image["links"]["self"]["href"]
+ object_uri = object_uri.replace("http://localhost:80", "")
+
+ with mock.patch("mediagoblin.decorators.oauth_required", new_callable=self.mocked_oauth_required):
+ request = test_app.get(object_uri)
+
+ image = json.loads(request.body)
+ entry = MediaEntry.query.filter_by(id=image["id"]).first()
+
+ assert request.status_code == 200
+ assert entry.id == image["id"]
+
+ assert "image" in image
+ assert "fullImage" in image
+ assert "pump_io" in image
+ assert "links" in image
def test_post_comment(self, test_app):
""" Tests that I can post an comment media """