Пример #1
0
    def test_has_enough_conviction(self):
        p = Proposal(500, 0.0)

        # a newly created Proposal can't expect to have any Conviction gathered at all
        self.assertFalse(p.has_enough_conviction(10000, 3e6, 0.2))

        p.conviction = 2666666.7
        self.assertTrue(p.has_enough_conviction(10000, 3e6, 0.2))
Пример #2
0
class TestProposal(unittest.TestCase):
    def setUp(self):
        self.p = Proposal(500, 0.0)

    def test_update_age(self):
        self.p.update_age()

        # The Proposal's age starts at 0 and should be incremented by 1 after update_age()
        self.assertEqual(self.p.age, 1)

    def test_update_threshold(self):
        # Just check if the trigger_threshold is correct
        self.assertEqual(self.p.update_threshold(500000.0, 3000.0, 10000.0), 1500.000300000045)

        # If the proposal status is not CANDIDATE, update_threshold shoud return NaN
        self.p.status = ProposalStatus.ACTIVE
        self.assertTrue(math.isnan(self.p.update_threshold(500000.0, 3000.0, 10000.0)))

    def test_has_enough_conviction(self):
        # a newly created Proposal can't expect to have any Conviction gathered at all
        self.assertFalse(self.p.has_enough_conviction(10000, 3e6, 0.2))

        self.p.conviction = 2666666.7
        self.assertTrue(self.p.has_enough_conviction(10000, 3e6, 0.2))