def test_restart_calls_pre_restart_on_old_and_post_on_new(): actor1 = Mock(spec_set=Actor) actor2 = Mock(spec_set=Actor) it = iter([actor1, actor2]) cell = Cell(lambda: next(it), Mock(), Mock(), Mock()) cell.handle_system_message(Start) cell.handle_system_message(Restart) actor1.pre_restart.assert_called_once_with() actor2.post_restart.assert_called_once_with()
def cell(factory): cell = Cell(factory, Mock(), Mock(), Mock()) cell.handle_system_message(Start) return cell
def test_start_calls_start_hook(actor): cell = Cell(lambda: actor, Mock(), Mock(), Mock()) cell.handle_system_message(Start) actor.pre_start.assert_called_once_with()
def test_failure_in_start_hook_should_send_failure_to_supervisor(actor, supervisor): actor.pre_start.side_effect = AttributeError() cell = Cell(lambda: actor, Mock(), Mock(), supervisor) cell.handle_system_message(Start) actor.pre_start.assert_called_once_with() _check_sent_failure_message(ActorRef(cell), supervisor, ActorInitializationError())
def running_cell(actor, supervisor): cell = Cell(lambda: actor, Mock(), Mock(), supervisor) cell.handle_system_message(Start) return cell
def test_start_constructs_instance(): factory = Mock() cell = Cell(factory, Mock(), Mock(), Mock()) cell.handle_system_message(Start) factory.assert_called_once_with()
def cell(actor): cell = Cell(lambda: actor, Mock(), Mock(), Mock()) cell.handle_system_message(Start) return cell
def test_sends_failure_if_factory_does_not_return_an_actor(supervisor): cell = Cell(lambda: object(), Mock(), Mock(), supervisor) cell.handle_system_message(Start) _check_sent_failure_message(ActorRef(cell), supervisor, ActorInitializationError())
def test_start_calls_start_hook(actor): cell = Cell(lambda: actor, Mock(), Mock(), Mock()) cell.handle_system_message(Start) actor.pre_start.assert_called_once_with()
def test_start_constructs_instance(): factory = Mock() cell = Cell(factory, Mock(), Mock(), Mock()) cell.handle_system_message(Start) factory.assert_called_once_with()
def running_cell(actor, supervisor): cell = Cell(lambda: actor, Mock(), Mock(), supervisor) cell.handle_system_message(Start) return cell
def test_sends_failure_if_factory_does_not_return_an_actor(supervisor): cell = Cell(lambda: object(), Mock(), Mock(), supervisor) cell.handle_system_message(Start) _check_sent_failure_message(ActorRef(cell), supervisor, ActorInitializationError())
def cell(actor, system, dispatcher, supervisor, mailbox): cell = Cell(lambda: actor, system, dispatcher, supervisor) cell._mailbox = mailbox cell.handle_system_message(Start) return cell