def test_comment_order_depth(self): sort = operators.desc("_confidence") builder = CommentBuilder(self.link, sort, num=1500, max_depth=1) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual(comment_order, [100, 107, 108, 109]) self.assertEqual(builder.missing_root_comments, set()) self.assertEqual(builder.missing_root_count, 0)
def test_comment_order_limit(self): sort = operators.desc("_confidence") builder = CommentBuilder(self.link, sort, num=5) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual(comment_order, [100, 101, 102, 104, 105]) self.assertEqual(builder.missing_root_comments, {107, 108, 109}) self.assertEqual(builder.missing_root_count, 4)
def test_comment_order_qa_multiple_responders(self): self.link.responder_ids = ("c", "d", "e") sort = operators.desc("_qa") builder = CommentBuilder(self.link, sort, num=1500) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual(comment_order, [100, 102, 104, 105, 106, 103, 107, 108, 109]) self.assertEqual(builder.missing_root_comments, set()) self.assertEqual(builder.missing_root_count, 0)
def test_comment_order_permalink(self): sort = operators.desc("_confidence") comment = MagicMock() comment._id = 100 builder = CommentBuilder(self.link, sort, comment=comment, num=1500) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual(comment_order, [100, 101, 102, 104, 105, 106, 103]) self.assertEqual(builder.missing_root_comments, set()) self.assertEqual(builder.missing_root_count, 0)
def test_comment_order_full_asc(self): sort = operators.asc("_confidence") builder = CommentBuilder(self.link, sort, num=1500) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual( comment_order, [109, 108, 107, 100, 103, 102, 106, 105, 101, 104, 110]) self.assertEqual(builder.missing_root_comments, set()) self.assertEqual(builder.missing_root_count, 0)
def test_comment_order_children_limit(self): sort = operators.desc("_confidence") builder = CommentBuilder(self.link, sort, children=[107, 108, 109], num=3) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual(comment_order, [107, 108, 110]) self.assertEqual(builder.missing_root_comments, {109}) self.assertEqual(builder.missing_root_count, 1)
def test_comment_order_children(self): sort = operators.desc("_confidence") builder = CommentBuilder(self.link, sort, children=[101, 102, 103], num=1500) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual(comment_order, [101, 102, 104, 105, 106, 103]) self.assertEqual(builder.missing_root_comments, set()) self.assertEqual(builder.missing_root_count, 0)
def test_comment_order_children_limit_bug(self): sort = operators.desc("_confidence") builder = CommentBuilder(self.link, sort, children=[101, 102, 103], num=3) builder.load_comment_order() comment_order = [ comment_tuple.comment_id for comment_tuple in builder.ordered_comment_tuples ] self.assertEqual(comment_order, [101, 102, 104]) # missing_root_comments SHOULD be {103}, but there's a bug here. # if the requested children are not root level but we don't show some # of them we should add a MoreChildren to allow a subsequent request # to get the missing comments. self.assertEqual(builder.missing_root_comments, set()) self.assertEqual(builder.missing_root_count, 0)