diff options
author | Jessica Tallon <tsyesika@tsyesika.se> | 2015-11-24 10:45:23 +0000 |
---|---|---|
committer | Jessica Tallon <tsyesika@tsyesika.se> | 2015-11-24 10:45:23 +0000 |
commit | 0d053bff98f32cc4f38456c705d38c32f557fe6d (patch) | |
tree | cb12c67a834b02f1a66f1818726404ce82336310 /mediagoblin/tests | |
parent | 34f1d8a264ac08f94051b6b07799270a96b7c666 (diff) | |
download | mediagoblin-0d053bff98f32cc4f38456c705d38c32f557fe6d.tar.lz mediagoblin-0d053bff98f32cc4f38456c705d38c32f557fe6d.tar.xz mediagoblin-0d053bff98f32cc4f38456c705d38c32f557fe6d.zip |
Added test for #5356 - Read someone else's feed
This adds a test and improves a previous test for the ability to read
someone elses feed. Previously it was not possible however this has
since been patched and this test checks for that.
Diffstat (limited to 'mediagoblin/tests')
-rw-r--r-- | mediagoblin/tests/test_api.py | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py index 205b8a69..10bf08fe 100644 --- a/mediagoblin/tests/test_api.py +++ b/mediagoblin/tests/test_api.py @@ -25,7 +25,7 @@ from webtest import AppError from .resources import GOOD_JPG from mediagoblin import mg_globals -from mediagoblin.db.models import User, MediaEntry, TextComment +from mediagoblin.db.models import User, Activity, MediaEntry, TextComment from mediagoblin.tools.routing import extract_url_arguments from mediagoblin.tests.tools import fixture_add_user from mediagoblin.moderation.tools import take_away_privileges @@ -458,7 +458,40 @@ class TestAPI(object): # Check that image i uploaded is there assert feed["items"][0]["verb"] == "post" - assert feed["items"][0]["actor"] + assert feed["items"][0]["id"] == data["id"] + assert feed["items"][0]["object"]["objectType"] == "image" + assert feed["items"][0]["object"]["id"] == data["object"]["id"] + + + def test_read_another_feed(self, test_app): + """ Test able to read objects from someone else's feed """ + response, data = self._upload_image(test_app, GOOD_JPG) + response, data = self._post_image_to_feed(test_app, data) + + # Change the active user to someone else. + self.active_user = self.other_user + + # Fetch the feed + url = "/api/user/{0}/feed".format(self.user.username) + with self.mock_oauth(): + response = test_app.get(url) + feed = json.loads(response.body.decode()) + + assert response.status_code == 200 + + # Check it has the attributes it ought to. + assert "displayName" in feed + assert "objectTypes" in feed + assert "url" in feed + assert "links" in feed + assert "author" in feed + assert "items" in feed + + # Assert the uploaded image is there + assert feed["items"][0]["verb"] == "post" + assert feed["items"][0]["id"] == data["id"] + assert feed["items"][0]["object"]["objectType"] == "image" + assert feed["items"][0]["object"]["id"] == data["object"]["id"] def test_cant_post_to_someone_elses_feed(self, test_app): """ Test that can't post to someone elses feed """ |