Esempio n. 1
0
    def test_current_articles_helpful(self):
        """Doesn't return helpful votes within time range"""
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 1, 3)

        for x in range(0, 2):
            _add_vote_in_past(r, 0, 3)

        old_data = {r.id: {'percentage': 0.2, 'total': 5.0}}

        result = _get_current_unhelpful(old_data)
        eq_(0, len(result))
Esempio n. 2
0
    def test_current_articles_helpful(self):
        """Doesn't return helpful votes within time range"""
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 1, 3)

        for x in range(0, 2):
            _add_vote_in_past(r, 0, 3)

        old_data = {r.id: {'percentage': 0.2, 'total': 5.0}}

        result = _get_current_unhelpful(old_data)
        eq_(0, len(result))
Esempio n. 3
0
    def test_current_articles_helpful(self):
        """
        Make sure _get_current_unhelpful() doesn't return a helpful (no < yes)
        with votes within time range.
        """
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 1, 15)

        for x in range(0, 2):
            _add_vote_in_past(r, 0, 15)

        old_data = {r.id: {"percentage": 0.2, "total": 5.0}}

        result = _get_current_unhelpful(old_data)
        eq_(0, len(result))
Esempio n. 4
0
    def test_current_articles_not_in_old(self):
        """Unhelpful articles in current but not in old works"""
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 0, 3)

        for x in range(0, 2):
            _add_vote_in_past(r, 1, 3)

        old_data = {}

        result = _get_current_unhelpful(old_data)
        eq_(1, len(result))
        self.assertAlmostEqual(0.4, result[r.id]['currperc'])
        self.assertAlmostEqual(0, result[r.id]['diffperc'])
        eq_(5, result[r.id]['total'])
Esempio n. 5
0
    def test_current_articles_not_in_old(self):
        """Unhelpful articles in current but not in old works"""
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 0, 3)

        for x in range(0, 2):
            _add_vote_in_past(r, 1, 3)

        old_data = {}

        result = _get_current_unhelpful(old_data)
        eq_(1, len(result))
        self.assertAlmostEqual(0.4, result[r.id]['currperc'])
        self.assertAlmostEqual(0, result[r.id]['diffperc'])
        eq_(5, result[r.id]['total'])
Esempio n. 6
0
    def test_current_articles(self):
        """Returns unhelpful votes within time range"""
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 0, 3)

        for x in range(0, 2):
            _add_vote_in_past(r, 1, 3)

        old_data = {r.id: {'percentage': 0.2, 'total': 5.0}}

        result = _get_current_unhelpful(old_data)
        eq_(1, len(result))
        self.assertAlmostEqual(0.4, result[r.id]['currperc'])
        self.assertAlmostEqual(0.4 - old_data[r.id]['percentage'],
                               result[r.id]['diffperc'])
        eq_(5, result[r.id]['total'])
Esempio n. 7
0
    def test_current_articles(self):
        """Returns unhelpful votes within time range"""
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 0, 3)

        for x in range(0, 2):
            _add_vote_in_past(r, 1, 3)

        old_data = {r.id: {'percentage': 0.2, 'total': 5.0}}

        result = _get_current_unhelpful(old_data)
        eq_(1, len(result))
        self.assertAlmostEqual(0.4, result[r.id]['currperc'])
        self.assertAlmostEqual(0.4 - old_data[r.id]['percentage'],
                               result[r.id]['diffperc'])
        eq_(5, result[r.id]['total'])
Esempio n. 8
0
    def test_current_articles_not_in_old(self):
        """
        Unhelpful articles in current but not in old shouldn't break stuff.
        """
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 0, 15)

        for x in range(0, 2):
            _add_vote_in_past(r, 1, 15)

        old_data = {}

        result = _get_current_unhelpful(old_data)
        eq_(1, len(result))
        self.assertAlmostEqual(0.4, result[r.id]["currperc"])
        self.assertAlmostEqual(0, result[r.id]["diffperc"])
        eq_(5, result[r.id]["total"])
Esempio n. 9
0
    def test_current_articles(self):
        """
        Make sure _get_current_unhelpful() returns an unhelpful (no > yes) with
        votes within time range.
        """
        r = _make_backdated_revision(90)

        for x in range(0, 3):
            _add_vote_in_past(r, 0, 15)

        for x in range(0, 2):
            _add_vote_in_past(r, 1, 15)

        old_data = {r.id: {"percentage": 0.2, "total": 5.0}}

        result = _get_current_unhelpful(old_data)
        eq_(1, len(result))
        self.assertAlmostEqual(0.4, result[r.id]["currperc"])
        self.assertAlmostEqual(0.4 - old_data[r.id]["percentage"], result[r.id]["diffperc"])
        eq_(5, result[r.id]["total"])
Esempio n. 10
0
 def test_no_current_articles(self):
     """Make sure _get_current_articles() returns nothing with no votes."""
     result = _get_current_unhelpful({})
     eq_(0, len(result))
Esempio n. 11
0
 def test_no_current_articles(self):
     """Make sure _get_current_articles() returns nothing with no votes."""
     result = _get_current_unhelpful({})
     eq_(0, len(result))