diff options
author | Jessica Tallon <jessica@megworld.co.uk> | 2014-12-16 12:05:18 +0000 |
---|---|---|
committer | Jessica Tallon <jessica@megworld.co.uk> | 2014-12-16 12:05:18 +0000 |
commit | 9e715bb07f9a09f5594ed865d3dbd204c71feb50 (patch) | |
tree | 822f4d098b5f1f98caf9217166d491199d69e450 /mediagoblin/tests/test_api.py | |
parent | 9a51bf1ebcee16169c7dc8ab950b23f7b4a06a22 (diff) | |
download | mediagoblin-9e715bb07f9a09f5594ed865d3dbd204c71feb50.tar.lz mediagoblin-9e715bb07f9a09f5594ed865d3dbd204c71feb50.tar.xz mediagoblin-9e715bb07f9a09f5594ed865d3dbd204c71feb50.zip |
Fix #1077 - Fix updating comment via API and add test
Diffstat (limited to 'mediagoblin/tests/test_api.py')
-rw-r--r-- | mediagoblin/tests/test_api.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py index a4cb21d6..83003875 100644 --- a/mediagoblin/tests/test_api.py +++ b/mediagoblin/tests/test_api.py @@ -561,3 +561,40 @@ class TestAPI(object): assert "object" in delete assert delete["object"]["id"] == comment["object"]["id"] assert delete["object"]["objectType"] == "comment" + + def test_edit_comment(self, test_app): + """ Test that someone can update their own comment """ + # First upload an image to comment against + response, data = self._upload_image(test_app, GOOD_JPG) + response, data = self._post_image_to_feed(test_app, data) + + # Post a comment to edit + activity = { + "verb": "post", + "object": { + "objectType": "comment", + "content": "This is a comment", + "inReplyTo": data["object"], + } + } + + comment = self._activity_to_feed(test_app, activity)[1] + + # Now create an update activity to change the content + activity = { + "verb": "update", + "object": { + "id": comment["object"]["id"], + "content": "This is my fancy new content string!", + "objectType": "comment", + }, + } + + comment = self._activity_to_feed(test_app, activity)[1] + + # Verify the comment reflects the changes + comment_id = int(comment["object"]["id"].split("/")[-2]) + model = MediaComment.query.filter_by(id=comment_id).first() + + assert model.content == activity["object"]["content"] + |