get_hidden_claim_comments -> get_claim_hidden_comments

This commit is contained in:
Oleg Silkin 2019-08-04 18:21:07 -04:00
parent 28944ad9b3
commit ffb3711ac9
3 changed files with 9 additions and 9 deletions

View file

@ -73,7 +73,7 @@ def get_claim_comments(conn: sqlite3.Connection, claim_id: str, parent_id: str =
} }
def get_hidden_claim_comments(conn: sqlite3.Connection, claim_id: str, hidden=True, page=1, page_size=50): def get_claim_hidden_comments(conn: sqlite3.Connection, claim_id: str, hidden=True, page=1, page_size=50):
with conn: with conn:
results = conn.execute( results = conn.execute(
SELECT_COMMENTS_ON_CLAIMS + "WHERE claim_id = ? AND is_hidden = ? LIMIT ? OFFSET ?", SELECT_COMMENTS_ON_CLAIMS + "WHERE claim_id = ? AND is_hidden = ? LIMIT ? OFFSET ?",

View file

@ -10,7 +10,7 @@ from src.server.misc import clean_input_params
from src.database.queries import get_claim_comments from src.database.queries import get_claim_comments
from src.database.queries import get_comments_by_id, get_comment_ids from src.database.queries import get_comments_by_id, get_comment_ids
from src.database.queries import get_channel_id_from_comment_id from src.database.queries import get_channel_id_from_comment_id
from src.database.queries import get_hidden_claim_comments from src.database.queries import get_claim_hidden_comments
from src.server.misc import is_valid_base_comment from src.server.misc import is_valid_base_comment
from src.server.misc import is_valid_credential_input from src.server.misc import is_valid_credential_input
from src.server.misc import make_error from src.server.misc import make_error
@ -43,8 +43,8 @@ def handle_get_comments_by_id(app, kwargs):
return get_comments_by_id(app['reader'], **kwargs) return get_comments_by_id(app['reader'], **kwargs)
def handle_get_hidden_claim_comments(app, kwargs): def handle_get_claim_hidden_comments(app, kwargs):
return get_hidden_claim_comments(app['reader'], **kwargs) return get_claim_hidden_comments(app['reader'], **kwargs)
async def handle_create_comment(app, params): async def handle_create_comment(app, params):
@ -66,7 +66,7 @@ async def handle_hide_comment(app, params):
METHODS = { METHODS = {
'ping': ping, 'ping': ping,
'get_claim_comments': handle_get_claim_comments, 'get_claim_comments': handle_get_claim_comments,
'get_hidden_claim_comments': handle_get_hidden_claim_comments, 'get_claim_hidden_comments': handle_get_claim_hidden_comments,
'get_comment_ids': handle_get_comment_ids, 'get_comment_ids': handle_get_comment_ids,
'get_comments_by_id': handle_get_comments_by_id, 'get_comments_by_id': handle_get_comments_by_id,
'get_channel_from_comment_id': handle_get_channel_from_comment_id, 'get_channel_from_comment_id': handle_get_channel_from_comment_id,

View file

@ -8,7 +8,7 @@ from faker.providers import misc
from src.database.queries import get_comments_by_id from src.database.queries import get_comments_by_id
from src.database.queries import get_comment_ids from src.database.queries import get_comment_ids
from src.database.queries import get_claim_comments from src.database.queries import get_claim_comments
from src.database.queries import get_hidden_claim_comments from src.database.queries import get_claim_hidden_comments
from src.database.writes import create_comment_or_error from src.database.writes import create_comment_or_error
from src.database.queries import hide_comment_by_id from src.database.queries import hide_comment_by_id
from src.database.queries import delete_comment_by_id from src.database.queries import delete_comment_by_id
@ -263,17 +263,17 @@ class ListDatabaseTest(DatabaseTestCase):
self.assertFalse(comment_list['has_hidden_comments']) self.assertFalse(comment_list['has_hidden_comments'])
hide_comment_by_id(self.conn, comm2['comment_id']) hide_comment_by_id(self.conn, comm2['comment_id'])
default_comments = get_hidden_claim_comments(self.conn, claim_id) default_comments = get_claim_hidden_comments(self.conn, claim_id)
self.assertIn('has_hidden_comments', default_comments) self.assertIn('has_hidden_comments', default_comments)
hidden_comments = get_hidden_claim_comments(self.conn, claim_id, hidden=True) hidden_comments = get_claim_hidden_comments(self.conn, claim_id, hidden=True)
self.assertIn('has_hidden_comments', hidden_comments) self.assertIn('has_hidden_comments', hidden_comments)
self.assertEqual(default_comments, hidden_comments) self.assertEqual(default_comments, hidden_comments)
hidden_comment = hidden_comments['items'][0] hidden_comment = hidden_comments['items'][0]
self.assertEqual(hidden_comment['comment_id'], comm2['comment_id']) self.assertEqual(hidden_comment['comment_id'], comm2['comment_id'])
visible_comments = get_hidden_claim_comments(self.conn, claim_id, hidden=False) visible_comments = get_claim_hidden_comments(self.conn, claim_id, hidden=False)
self.assertIn('has_hidden_comments', visible_comments) self.assertIn('has_hidden_comments', visible_comments)
self.assertNotIn(hidden_comment, visible_comments['items']) self.assertNotIn(hidden_comment, visible_comments['items'])