コード例 #1
0
    def test_stale_v(self):
        view_est_mod = ViewEstablishmentModule(0, self.resolver, 2, 0)
        pred_module = PredicatesAndAction(view_est_mod, 0, self.resolver, 2, 0)

        # Stale and in phase 0
        view_est_mod.get_phs = MagicMock(return_value=0)
        pred_module.legit_phs_zero = MagicMock(return_value=False)
        pred_module.legit_phs_one = MagicMock(return_value=False)
        self.assertTrue(pred_module.stale_v(0))
        # Stale and in phase 1
        view_est_mod.get_phs = MagicMock(return_value=1)
        self.assertTrue(pred_module.stale_v(0))
        # Not stale
        pred_module.legit_phs_one = MagicMock(return_value=True)
        self.assertFalse(pred_module.stale_v(0))
コード例 #2
0
    def test_legit_phs_one(self):
        view_est_mod = ViewEstablishmentModule(0, self.resolver, 2, 0)
        pred_module = PredicatesAndAction(view_est_mod, 0, self.resolver, 2, 0)
        pred_module.type_check = MagicMock(return_value=True)
        vpair_to_test = {CURRENT: 1, NEXT: 2}

        # Legit to be in phase 1
        self.assertTrue(pred_module.legit_phs_one(vpair_to_test))

        # Not in a view change
        vpair_to_test = {CURRENT: 1, NEXT: 1}
        self.assertFalse(pred_module.legit_phs_one(vpair_to_test))

        # Type check fails
        vpair_to_test = {CURRENT: 1, NEXT: 2}
        pred_module.type_check = MagicMock(return_value=False)
        self.assertFalse(pred_module.legit_phs_one(vpair_to_test))