mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
renamed get_comments get_data
This commit is contained in:
parent
75ae087f7a
commit
338c349dd5
@ -157,7 +157,7 @@ class WebSupport(object):
|
|||||||
document['title'] = 'Search Results'
|
document['title'] = 'Search Results'
|
||||||
return document
|
return document
|
||||||
|
|
||||||
def get_comments(self, node_id, username=None, moderator=False):
|
def get_data(self, node_id, username=None, moderator=False):
|
||||||
"""Get the comments and source associated with `node_id`. If
|
"""Get the comments and source associated with `node_id`. If
|
||||||
`user_id` is given vote information will be included with the
|
`user_id` is given vote information will be included with the
|
||||||
returned comments. The default CommentBackend returns dict with
|
returned comments. The default CommentBackend returns dict with
|
||||||
@ -191,7 +191,7 @@ class WebSupport(object):
|
|||||||
:param node_id: the id of the node to get comments for.
|
:param node_id: the id of the node to get comments for.
|
||||||
:param user_id: the id of the user viewing the comments.
|
:param user_id: the id of the user viewing the comments.
|
||||||
"""
|
"""
|
||||||
return self.storage.get_comments(node_id, username, moderator)
|
return self.storage.get_data(node_id, username, moderator)
|
||||||
|
|
||||||
def add_comment(self, text, node_id='', parent_id='', displayed=True,
|
def add_comment(self, text, node_id='', parent_id='', displayed=True,
|
||||||
username=None, rating=0, time=None, proposal=None,
|
username=None, rating=0, time=None, proposal=None,
|
||||||
|
@ -58,7 +58,7 @@ class SQLAlchemyStorage(StorageBackend):
|
|||||||
session.close()
|
session.close()
|
||||||
return comment
|
return comment
|
||||||
|
|
||||||
def get_comments(self, node_id, username, moderator):
|
def get_data(self, node_id, username, moderator):
|
||||||
session = Session()
|
session = Session()
|
||||||
node = session.query(Node).filter(Node.id == node_id).one()
|
node = session.query(Node).filter(Node.id == node_id).one()
|
||||||
session.close()
|
session.close()
|
||||||
|
@ -91,7 +91,7 @@ def test_comments(support):
|
|||||||
node_id=str(second_node.id))
|
node_id=str(second_node.id))
|
||||||
|
|
||||||
# Access the comments as a moderator.
|
# Access the comments as a moderator.
|
||||||
data = support.get_comments(str(first_node.id), moderator=True)
|
data = support.get_data(str(first_node.id), moderator=True)
|
||||||
comments = data['comments']
|
comments = data['comments']
|
||||||
children = comments[0]['children']
|
children = comments[0]['children']
|
||||||
assert len(comments) == 2
|
assert len(comments) == 2
|
||||||
@ -100,7 +100,7 @@ def test_comments(support):
|
|||||||
assert children[1]['text'] == 'Hidden child test comment'
|
assert children[1]['text'] == 'Hidden child test comment'
|
||||||
|
|
||||||
# Access the comments without being a moderator.
|
# Access the comments without being a moderator.
|
||||||
data = support.get_comments(str(first_node.id))
|
data = support.get_data(str(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
|
||||||
@ -115,10 +115,10 @@ def test_voting(support):
|
|||||||
nodes = session.query(Node).all()
|
nodes = session.query(Node).all()
|
||||||
node = nodes[0]
|
node = nodes[0]
|
||||||
|
|
||||||
comment = support.get_comments(str(node.id))['comments'][0]
|
comment = support.get_data(str(node.id))['comments'][0]
|
||||||
|
|
||||||
def check_rating(val):
|
def check_rating(val):
|
||||||
data = support.get_comments(str(node.id))
|
data = support.get_data(str(node.id))
|
||||||
comment = data['comments'][0]
|
comment = data['comments'][0]
|
||||||
assert comment['rating'] == val, '%s != %s' % (comment['rating'], val)
|
assert comment['rating'] == val, '%s != %s' % (comment['rating'], val)
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ def test_voting(support):
|
|||||||
|
|
||||||
# Make sure past voting data is associated with comments when they are
|
# Make sure past voting data is associated with comments when they are
|
||||||
# fetched.
|
# fetched.
|
||||||
data = support.get_comments(str(node.id), username='user_two')
|
data = support.get_data(str(node.id), username='user_two')
|
||||||
comment = data['comments'][0]
|
comment = data['comments'][0]
|
||||||
assert comment['vote'] == 1, '%s != 1' % comment['vote']
|
assert comment['vote'] == 1, '%s != 1' % comment['vote']
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ def test_proposals(support):
|
|||||||
nodes = session.query(Node).all()
|
nodes = session.query(Node).all()
|
||||||
node = nodes[0]
|
node = nodes[0]
|
||||||
|
|
||||||
data = support.get_comments(str(node.id))
|
data = support.get_data(str(node.id))
|
||||||
|
|
||||||
source = data['source']
|
source = data['source']
|
||||||
proposal = source[:5] + source[10:15] + 'asdf' + source[15:]
|
proposal = source[:5] + source[10:15] + 'asdf' + source[15:]
|
||||||
|
Loading…
Reference in New Issue
Block a user