def test_legit_phs_zero(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: 1} # Legit to be in phase 0 self.assertTrue(pred_module.legit_phs_zero(vpair_to_test)) # Reset vpair, also legit vpair_to_test = pred_module.RST_PAIR self.assertTrue(pred_module.legit_phs_zero(vpair_to_test)) # In view change, not legit to be in phase 0 vpair_to_test = {CURRENT: 1, NEXT: 2} self.assertFalse(pred_module.legit_phs_zero(vpair_to_test)) # Type check fails vpair_to_test = {CURRENT: 1, NEXT: 1} pred_module.type_check = MagicMock(return_value=False) self.assertFalse(pred_module.legit_phs_zero(vpair_to_test))
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))