allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [06/10] allura git commit: [#8253] Add unit cases for reaction endpoint
Date Thu, 08 Nov 2018 21:53:47 GMT
[#8253] Add unit cases for reaction endpoint


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/de72730c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/de72730c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/de72730c

Branch: refs/heads/master
Commit: de72730c21558c1c4d75a244cbe296391b766cd4
Parents: 7181877
Author: Shalitha Suranga <shalithasuranga@gmail.com>
Authored: Wed Oct 31 14:25:04 2018 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Thu Nov 8 21:53:25 2018 +0000

----------------------------------------------------------------------
 Allura/allura/tests/functional/test_discuss.py | 63 +++++++++++++++++++++
 1 file changed, 63 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/de72730c/Allura/allura/tests/functional/test_discuss.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_discuss.py b/Allura/allura/tests/functional/test_discuss.py
index 74a490c..5539710 100644
--- a/Allura/allura/tests/functional/test_discuss.py
+++ b/Allura/allura/tests/functional/test_discuss.py
@@ -216,6 +216,69 @@ class TestDiscuss(TestDiscussBase):
             extra_environ=dict(username='*anonymous'))
         assert response.json['status'] == 'no_permission'
 
+    def test_comment_post_reaction_new(self):
+        r = self._make_post('This is a post')
+        post_id = str(
+            r.html.find('div', {'class': 'discussion-post'})['id'])
+        react_link = str(self._thread_link() + post_id + '/post_reaction')
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'heart'})
+        assert response.json['status'] == 'ok' and response.json['react_heart'] == 1
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'invalid'})
+        assert response.json['status'] == 'error' and response.json['react_heart'] == 1
+        # anon users can't react comments
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'heart'},
+            extra_environ=dict(username='*anonymous'))
+        assert response.json['error'] == 'no_permission'
+        # even anon can't send invalid reactions
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'invalid'},
+            extra_environ=dict(username='*anonymous'))
+        assert response.json['error'] == 'no_permission'
+
+    def test_comment_post_reaction_change(self):
+        r = self._make_post('This is a post')
+        post_id = str(
+            r.html.find('div', {'class': 'discussion-post'})['id'])
+        react_link = str(self._thread_link() + post_id + '/post_reaction')
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'thumbs_down'})
+        assert response.json['status'] == 'ok' and response.json['react_thumbs_down'] ==
1
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'thumbs_up'})
+        assert response.json['status'] == 'ok' and response.json['react_thumbs_up'] == 1
+        assert response.json['status'] == 'ok' and response.json['react_thumbs_down'] ==
0
+
+    def test_comment_post_reaction_undo(self):
+        r = self._make_post('This is a post')
+        post_id = str(
+            r.html.find('div', {'class': 'discussion-post'})['id'])
+        react_link = str(self._thread_link() + post_id + '/post_reaction')
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'hooray'})
+        assert response.json['status'] == 'ok' and response.json['react_hooray'] == 1
+        response = self.app.post(
+            react_link,
+            params={
+                'r': 'hooray'})
+        assert response.json['status'] == 'ok' and response.json['react_hooray'] == 0
+
     def test_user_filter(self):
         r = self._make_post('Test post')
         post_link = str(


Mime
View raw message