Exemplo n.º 1
0
    def test_pa_score(self):
        score = [PAScore(IntegerScore(x)) for x in range(0, 11)]

        self.assertLess(score[0], score[5])
        self.assertLess(score[5], score[10])
        self.assertLess(score[5] + score[5], score[10])
        self.assertLess(score[5] + score[5], score[2] + score[2] + score[6])
        self.assertLess(score[10], score[2] + score[4] + score[5])
        self.assertLess(score[2] + score[2] + score[6],
                        score[1] + score[3] + score[6])

        dist1 = ScoreDistribution([0] * 8 + [2, 4])
        dist2 = ScoreDistribution([0] * 8 + [1, 6])
        score1 = PAScore(IntegerScore(8), dist1)
        score2 = PAScore(IntegerScore(8), dist2)
        self.assertLess(score2, score1)

        score3 = score[10] + score[10] + score[10] + score[4] + score[2] + \
                score1 + score2

        self.assertEqual(score3, (3 * 10 + 4 + 2 + 2 * 8))
        self.assertEqual(
            repr(score3),
            'PAScore(IntegerScore(52), ScoreDistribution(10: 3, 9: 0, 8: '
            '0, 7: 0, 6: 0, 5: 0, 4: 1, 3: 0, 2: 4, 1: 10))')
        self.assertEqual(
            score3._to_repr(), '0000000000000000052;00003:00000:'
            '00000:00000:00000:00000:00001:00000:00004:00010')
        self.assertEqual(score3, PAScore._from_repr(score3._to_repr()))
Exemplo n.º 2
0
    def test_pa_score(self):
        score = [PAScore(IntegerScore(x)) for x in range(0, 11)]

        self.assertLess(score[0], score[5])
        self.assertLess(score[5], score[10])
        self.assertLess(score[5] + score[5], score[10])
        self.assertLess(score[5] + score[5], score[2] + score[2] + score[6])
        self.assertLess(score[10], score[2] + score[4] + score[5])
        self.assertLess(score[2] + score[2] + score[6],
                score[1] + score[3] + score[6])

        dist1 = ScoreDistribution([0] * 8 + [2, 4])
        dist2 = ScoreDistribution([0] * 8 + [1, 6])
        score1 = PAScore(IntegerScore(8), dist1)
        score2 = PAScore(IntegerScore(8), dist2)
        self.assertLess(score2, score1)

        score3 = score[10] + score[10] + score[10] + score[4] + score[2] + \
                score1 + score2

        self.assertEqual(unicode(score3), str(3 * 10 + 4 + 2 + 2 * 8))
        self.assertEqual(repr(score3),
                'PAScore(IntegerScore(52), ScoreDistribution(10: 3, 9: 0, 8: '
                '0, 7: 0, 6: 0, 5: 0, 4: 1, 3: 0, 2: 4, 1: 10))')
        self.assertEqual(score3._to_repr(), '0000000000000000052;00003:00000:'
                '00000:00000:00000:00000:00001:00000:00004:00010')
        self.assertEqual(score3, PAScore._from_repr(score3._to_repr()))
Exemplo n.º 3
0
 def update_user_result_for_problem(self, result):
     super(PAContestController, self).update_user_result_for_problem(result)
     if result.score is not None:
         result.score = PAScore(result.score)
Exemplo n.º 4
0
 def pa_score_factory(int_score):
     return PAScore(IntegerScore(int_score))