'Tests if Bayesian Average sorting works correctly.'

def test_caching_sorting(self):

    r = _make_backdated_revision(90)
    for x in range(0, 26):
        _add_vote_in_past(r, 1, 3)
    for x in range(0, 76):
        _add_vote_in_past(r, 0, 3)
    r2 = _make_backdated_revision(90)
    for x in range(0, 61):
        _add_vote_in_past(r2, 1, 3)
    for x in range(0, 181):
        _add_vote_in_past(r2, 0, 3)
    r3 = _make_backdated_revision(90)
    for x in range(0, 31):
        _add_vote_in_past(r3, 1, 3)
    for x in range(0, 91):
        _add_vote_in_past(r3, 0, 3)
    cache_most_unhelpful_kb_articles()
    eq_(3, self.redis.llen(self.REDIS_KEY))
    result = self.redis.lrange(self.REDIS_KEY, 0, 3)
    assert (('%d::%.1f:' % (r2.document.id, 242.0)) in result[0])
    assert (('%d::%.1f:' % (r3.document.id, 122.0)) in result[1])
    assert (('%d::%.1f:' % (r.document.id, 102.0)) in result[2])
