

@pytest.mark.parametrize('inport_ret_val,outport_ret_val,expected', [(False, False, False), (False, True, False), (True, False, False), (True, True, True)])
def test_did_connect(actor, inport_ret_val, outport_ret_val, expected):
    for port in actor.inports.values():
        port.is_connected = Mock(return_value=inport_ret_val)
    for port in actor.outports.values():
        port.is_connected = Mock(return_value=outport_ret_val)
    actor.fsm = Mock()
    actor.did_connect(None)
    if expected:
        actor.fsm.transition_to.assert_called_with(Actor.STATUS.ENABLED)
        assert actor._calvinsys.scheduler_wakeup.called
    else:
        assert (not actor.fsm.transition_to.called)
        assert (not actor._calvinsys.scheduler_wakeup.called)

dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/tests/test_actor.py test_did_connect/original