summaryrefslogtreecommitdiff
path: root/tests/test_websupport.py
diff options
context:
space:
mode:
authorJacob Mason <jacoblmason@gmail.com>2010-08-04 16:06:10 -0500
committerJacob Mason <jacoblmason@gmail.com>2010-08-04 16:06:10 -0500
commit69a2c07396f94ec0099c24089dd452b30cc06052 (patch)
tree444706a703da238c7a2c55deff7c931a956a5514 /tests/test_websupport.py
parentf58fe6eed69a40c962bac57e672ec0d41b4a714c (diff)
downloadsphinx-git-69a2c07396f94ec0099c24089dd452b30cc06052.tar.gz
added delete_comment method
Diffstat (limited to 'tests/test_websupport.py')
-rw-r--r--tests/test_websupport.py46
1 files changed, 42 insertions, 4 deletions
diff --git a/tests/test_websupport.py b/tests/test_websupport.py
index bfa07226f..ca64ec2d1 100644
--- a/tests/test_websupport.py
+++ b/tests/test_websupport.py
@@ -79,11 +79,13 @@ def test_comments(support):
# Create a displayed comment and a non displayed comment.
comment = support.add_comment('First test comment',
- node_id=str(first_node.id))
+ node_id=str(first_node.id),
+ username='user_one')
support.add_comment('Hidden comment', node_id=str(first_node.id),
displayed=False)
# Add a displayed and not displayed child to the displayed comment.
- support.add_comment('Child test comment', parent_id=str(comment['id']))
+ support.add_comment('Child test comment', parent_id=str(comment['id']),
+ username='user_one')
support.add_comment('Hidden child test comment',
parent_id=str(comment['id']), displayed=False)
# Add a comment to another node to make sure it isn't returned later.
@@ -144,8 +146,7 @@ def test_voting(support):
@with_support()
def test_proposals(support):
session = Session()
- nodes = session.query(Node).all()
- node = nodes[0]
+ node = session.query(Node).first()
data = support.get_data(str(node.id))
@@ -156,6 +157,43 @@ def test_proposals(support):
node_id=str(node.id),
proposal=proposal)
+
+@with_support()
+def test_user_delete_comments(support):
+ def get_comment():
+ session = Session()
+ node = session.query(Node).first()
+ session.close()
+ return support.get_data(str(node.id))['comments'][0]
+
+ comment = get_comment()
+ assert comment['username'] == 'user_one'
+ # Make sure other normal users can't delete someone elses comments.
+ raises(UserNotAuthorizedError, support.delete_comment,
+ comment['id'], username='user_two')
+ # Now delete the comment using the correct username.
+ support.delete_comment(comment['id'], username='user_one')
+ comment = get_comment()
+ assert comment['username'] == '[deleted]'
+ assert comment['text'] == '[deleted]'
+
+
+@with_support()
+def test_moderator_delete_comments(support):
+ def get_comment():
+ session = Session()
+ node = session.query(Node).first()
+ session.close()
+ return support.get_data(str(node.id), moderator=True)['comments'][1]
+
+ comment = get_comment()
+ support.delete_comment(comment['id'], username='user_two',
+ moderator=True)
+ comment = get_comment()
+ assert comment['username'] == '[deleted]'
+ assert comment['text'] == '[deleted]'
+
+
def test_differ():
differ = CombinedHtmlDiff()
source = 'Lorem ipsum dolor sit amet,\nconsectetur adipisicing elit,\n' \