def test_interface_get_current_view(self): view_est_mod = ViewEstablishmentModule(0, self.resolver, 2, 0) pred_module = PredicatesAndAction(view_est_mod, 0, self.resolver, 2, 0) pred_module.views = [{CURRENT: 0, NEXT: 0}, {CURRENT: 1, NEXT: 1}] view_est_mod.get_phs = MagicMock(return_value=1) view_est_mod.witnes_seen = MagicMock(return_value=True) pred_module.allow_service = MagicMock(return_value=True) # Should return the view of the current node self.assertEqual(pred_module.get_current_view(0), 0) # Should return the view of an other processor self.assertEqual(pred_module.get_current_view(1), 1) # Should give back the TEE (None) by denying service view_est_mod.get_phs = MagicMock(return_value=0) pred_module.allow_service = MagicMock(return_value=False) self.assertEqual(pred_module.get_current_view(0), ViewEstablishmentEnums.TEE)
def test_interface_allow_service(self): view_est_mod = ViewEstablishmentModule(0, self.resolver, 6, 1) pred_module = PredicatesAndAction(view_est_mod, 0, self.resolver, 6, 1) # Allow service settings view_est_mod.get_phs = MagicMock(return_value=0) pred_module.views = [{CURRENT: 0, NEXT: 0}] pred_module.same_v_set = MagicMock(return_value={0, 1, 2, 3, 4, 5}) self.assertTrue(pred_module.allow_service()) #Deny service settings, creating a false statement for each condition view_est_mod.get_phs = MagicMock(return_value=1) self.assertFalse(pred_module.allow_service()) view_est_mod.get_phs = MagicMock(return_value=0) pred_module.views = [{CURRENT: 0, NEXT: 1}] self.assertFalse(pred_module.allow_service()) pred_module.views = [{CURRENT: 0, NEXT: 0}] pred_module.same_v_set = MagicMock(return_value={}) self.assertFalse(pred_module.allow_service())