From d07fe37744934e4da12e3fb82cdb5420439a5a71 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 6 Oct 2011 14:28:18 +0200 Subject: [PATCH] Update the websupport tests to API changes. --- sphinx/themes/basic/static/websupport.js | 2 +- tests/test_websupport.py | 30 ++++++++++-------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/sphinx/themes/basic/static/websupport.js b/sphinx/themes/basic/static/websupport.js index cbb609232..e9bd1b851 100644 --- a/sphinx/themes/basic/static/websupport.js +++ b/sphinx/themes/basic/static/websupport.js @@ -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(); diff --git a/tests/test_websupport.py b/tests/test_websupport.py index 87cc6ad4f..d7b5fb32a 100644 --- a/tests/test_websupport.py +++ b/tests/test_websupport.py @@ -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'] == '

Hidden comment

\n' assert len(children) == 2 - assert children[1]['text'] == 'Hidden child test comment' + assert children[1]['text'] == '

Hidden child test comment

\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'] == '

First test comment

\n' assert len(children) == 1 - assert children[0]['text'] == 'Child test comment' + assert children[0]['text'] == '

Child test comment

\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']