mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Update the websupport tests to API changes.
This commit is contained in:
parent
608edd427c
commit
d07fe37744
@ -566,7 +566,7 @@
|
||||
var context = $.extend({}, opts, comment);
|
||||
var div = $(renderTemplate(commentTemplate, context));
|
||||
|
||||
// If the user has voted on this comment, highblight the correct arrow.
|
||||
// If the user has voted on this comment, highlight the correct arrow.
|
||||
if (comment.vote) {
|
||||
var direction = (comment.vote == 1) ? 'u' : 'd';
|
||||
div.find('#' + direction + 'v' + comment.id).hide();
|
||||
|
@ -18,8 +18,6 @@ except ImportError:
|
||||
# functools is new in 2.5
|
||||
wraps = lambda f: (lambda w: w)
|
||||
|
||||
from nose import SkipTest
|
||||
|
||||
from sphinx.websupport import WebSupport
|
||||
from sphinx.websupport.errors import *
|
||||
from sphinx.websupport.storage import StorageBackend
|
||||
@ -35,8 +33,6 @@ except ImportError:
|
||||
from util import *
|
||||
|
||||
|
||||
raise SkipTest('websupport tests are currently not working')
|
||||
|
||||
default_settings = {'builddir': os.path.join(test_root, 'websupport'),
|
||||
'status': StringIO(),
|
||||
'warning': StringIO()}
|
||||
@ -121,18 +117,18 @@ def test_comments(support):
|
||||
comments = data['comments']
|
||||
children = comments[0]['children']
|
||||
assert len(comments) == 2
|
||||
assert comments[1]['text'] == 'Hidden comment'
|
||||
assert comments[1]['text'] == '<p>Hidden comment</p>\n'
|
||||
assert len(children) == 2
|
||||
assert children[1]['text'] == 'Hidden child test comment'
|
||||
assert children[1]['text'] == '<p>Hidden child test comment</p>\n'
|
||||
|
||||
# Access the comments without being a moderator.
|
||||
data = support.get_data(first_node.id)
|
||||
comments = data['comments']
|
||||
children = comments[0]['children']
|
||||
assert len(comments) == 1
|
||||
assert comments[0]['text'] == 'First test comment'
|
||||
assert comments[0]['text'] == '<p>First test comment</p>\n'
|
||||
assert len(children) == 1
|
||||
assert children[0]['text'] == 'Child test comment'
|
||||
assert children[0]['text'] == '<p>Child test comment</p>\n'
|
||||
|
||||
|
||||
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||
@ -218,9 +214,7 @@ def test_moderator_delete_comments(support):
|
||||
comment = get_comment()
|
||||
support.delete_comment(comment['id'], username='user_two',
|
||||
moderator=True)
|
||||
comment = get_comment()
|
||||
assert comment['username'] == '[deleted]'
|
||||
assert comment['text'] == '[deleted]'
|
||||
raises(IndexError, get_comment)
|
||||
|
||||
|
||||
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||
@ -232,14 +226,14 @@ def test_update_username(support):
|
||||
filter(Comment.username == 'user_two').all()
|
||||
assert len(comments) == 0
|
||||
votes = session.query(CommentVote).\
|
||||
filter(CommentVote.username == 'user_two')
|
||||
assert len(comments) == 0
|
||||
filter(CommentVote.username == 'user_two').all()
|
||||
assert len(votes) == 0
|
||||
comments = session.query(Comment).\
|
||||
filter(Comment.username == 'new_user_two').all()
|
||||
assert len(comments) == 1
|
||||
votes = session.query(CommentVote).\
|
||||
filter(CommentVote.username == 'new_user_two')
|
||||
assert len(comments) == 1
|
||||
filter(CommentVote.username == 'new_user_two').all()
|
||||
assert len(votes) == 0
|
||||
|
||||
|
||||
called = False
|
||||
@ -257,15 +251,15 @@ def test_moderation(support):
|
||||
session.close()
|
||||
accepted = support.add_comment('Accepted Comment', node_id=node.id,
|
||||
displayed=False)
|
||||
rejected = support.add_comment('Rejected comment', node_id=node.id,
|
||||
deleted = support.add_comment('Comment to delete', node_id=node.id,
|
||||
displayed=False)
|
||||
# Make sure the moderation_callback is called.
|
||||
assert called == True
|
||||
# Make sure the user must be a moderator.
|
||||
raises(UserNotAuthorizedError, support.accept_comment, accepted['id'])
|
||||
raises(UserNotAuthorizedError, support.reject_comment, accepted['id'])
|
||||
raises(UserNotAuthorizedError, support.delete_comment, deleted['id'])
|
||||
support.accept_comment(accepted['id'], moderator=True)
|
||||
support.reject_comment(rejected['id'], moderator=True)
|
||||
support.delete_comment(deleted['id'], moderator=True)
|
||||
comments = support.get_data(node.id)['comments']
|
||||
assert len(comments) == 1
|
||||
comments = support.get_data(node.id, moderator=True)['comments']
|
||||
|
Loading…
Reference in New Issue
Block a user