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 context = $.extend({}, opts, comment);
|
||||||
var div = $(renderTemplate(commentTemplate, context));
|
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) {
|
if (comment.vote) {
|
||||||
var direction = (comment.vote == 1) ? 'u' : 'd';
|
var direction = (comment.vote == 1) ? 'u' : 'd';
|
||||||
div.find('#' + direction + 'v' + comment.id).hide();
|
div.find('#' + direction + 'v' + comment.id).hide();
|
||||||
|
@ -18,8 +18,6 @@ except ImportError:
|
|||||||
# functools is new in 2.5
|
# functools is new in 2.5
|
||||||
wraps = lambda f: (lambda w: w)
|
wraps = lambda f: (lambda w: w)
|
||||||
|
|
||||||
from nose import SkipTest
|
|
||||||
|
|
||||||
from sphinx.websupport import WebSupport
|
from sphinx.websupport import WebSupport
|
||||||
from sphinx.websupport.errors import *
|
from sphinx.websupport.errors import *
|
||||||
from sphinx.websupport.storage import StorageBackend
|
from sphinx.websupport.storage import StorageBackend
|
||||||
@ -35,8 +33,6 @@ except ImportError:
|
|||||||
from util import *
|
from util import *
|
||||||
|
|
||||||
|
|
||||||
raise SkipTest('websupport tests are currently not working')
|
|
||||||
|
|
||||||
default_settings = {'builddir': os.path.join(test_root, 'websupport'),
|
default_settings = {'builddir': os.path.join(test_root, 'websupport'),
|
||||||
'status': StringIO(),
|
'status': StringIO(),
|
||||||
'warning': StringIO()}
|
'warning': StringIO()}
|
||||||
@ -121,18 +117,18 @@ def test_comments(support):
|
|||||||
comments = data['comments']
|
comments = data['comments']
|
||||||
children = comments[0]['children']
|
children = comments[0]['children']
|
||||||
assert len(comments) == 2
|
assert len(comments) == 2
|
||||||
assert comments[1]['text'] == 'Hidden comment'
|
assert comments[1]['text'] == '<p>Hidden comment</p>\n'
|
||||||
assert len(children) == 2
|
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.
|
# Access the comments without being a moderator.
|
||||||
data = support.get_data(first_node.id)
|
data = support.get_data(first_node.id)
|
||||||
comments = data['comments']
|
comments = data['comments']
|
||||||
children = comments[0]['children']
|
children = comments[0]['children']
|
||||||
assert len(comments) == 1
|
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 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')
|
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||||
@ -218,9 +214,7 @@ def test_moderator_delete_comments(support):
|
|||||||
comment = get_comment()
|
comment = get_comment()
|
||||||
support.delete_comment(comment['id'], username='user_two',
|
support.delete_comment(comment['id'], username='user_two',
|
||||||
moderator=True)
|
moderator=True)
|
||||||
comment = get_comment()
|
raises(IndexError, get_comment)
|
||||||
assert comment['username'] == '[deleted]'
|
|
||||||
assert comment['text'] == '[deleted]'
|
|
||||||
|
|
||||||
|
|
||||||
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
@skip_if(sqlalchemy_missing, 'needs sqlalchemy')
|
||||||
@ -232,14 +226,14 @@ def test_update_username(support):
|
|||||||
filter(Comment.username == 'user_two').all()
|
filter(Comment.username == 'user_two').all()
|
||||||
assert len(comments) == 0
|
assert len(comments) == 0
|
||||||
votes = session.query(CommentVote).\
|
votes = session.query(CommentVote).\
|
||||||
filter(CommentVote.username == 'user_two')
|
filter(CommentVote.username == 'user_two').all()
|
||||||
assert len(comments) == 0
|
assert len(votes) == 0
|
||||||
comments = session.query(Comment).\
|
comments = session.query(Comment).\
|
||||||
filter(Comment.username == 'new_user_two').all()
|
filter(Comment.username == 'new_user_two').all()
|
||||||
assert len(comments) == 1
|
assert len(comments) == 1
|
||||||
votes = session.query(CommentVote).\
|
votes = session.query(CommentVote).\
|
||||||
filter(CommentVote.username == 'new_user_two')
|
filter(CommentVote.username == 'new_user_two').all()
|
||||||
assert len(comments) == 1
|
assert len(votes) == 0
|
||||||
|
|
||||||
|
|
||||||
called = False
|
called = False
|
||||||
@ -257,15 +251,15 @@ def test_moderation(support):
|
|||||||
session.close()
|
session.close()
|
||||||
accepted = support.add_comment('Accepted Comment', node_id=node.id,
|
accepted = support.add_comment('Accepted Comment', node_id=node.id,
|
||||||
displayed=False)
|
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)
|
displayed=False)
|
||||||
# Make sure the moderation_callback is called.
|
# Make sure the moderation_callback is called.
|
||||||
assert called == True
|
assert called == True
|
||||||
# Make sure the user must be a moderator.
|
# Make sure the user must be a moderator.
|
||||||
raises(UserNotAuthorizedError, support.accept_comment, accepted['id'])
|
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.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']
|
comments = support.get_data(node.id)['comments']
|
||||||
assert len(comments) == 1
|
assert len(comments) == 1
|
||||||
comments = support.get_data(node.id, moderator=True)['comments']
|
comments = support.get_data(node.id, moderator=True)['comments']
|
||||||
|
Loading…
Reference in New Issue
Block a user