847
847
self.assertFalse(self.aq.queue.active)
850
class TestStateManagerPassToNetworkManager(Base):
851
"""All network events should go to NetworkManager."""
853
@defer.inlineCallbacks
855
yield super(TestStateManagerPassToNetworkManager,
858
# put a function in the middle to log calls
859
self.called_events = []
860
orig_on_event = self.sm.connection.on_event
861
def fake_on_event(event):
862
"""Log the call and call original."""
863
self.called_events.append(event)
865
self.sm.connection.on_event = fake_on_event
867
def _test(self, event):
868
"""Generic test method."""
870
for node in self.sm_nodes_ok:
873
self.sm.handle_default(event)
874
self.assertEqual(self.called_events, [event]*cnt)
876
def test_net_connected(self):
877
"""SYS_NET_CONNECTED should go to Connection no matter where."""
878
self._test('SYS_NET_CONNECTED')
880
def test_user_connect(self):
881
"""SYS_USER_CONNECT should go to Connection no matter where."""
882
self._test('SYS_USER_CONNECT')
884
def test_net_disconnected(self):
885
"""SYS_NET_DISCONNECTED should go to Connection no matter where."""
886
self._test('SYS_NET_DISCONNECTED')
888
def test_user_disconnect(self):
889
"""SYS_USER_DISCONNECT should go to Connection no matter where."""
890
self._test('SYS_USER_DISCONNECT')
892
def test_connection_lost(self):
893
"""SYS_CONNECTION_LOST should go to Connection no matter where."""
894
self._test('SYS_CONNECTION_LOST')
896
def test_handshake_timeout(self):
897
"""SYS_HANDSHAKE_TIMEOUT should go to Connection no matter where."""
898
self._test('SYS_HANDSHAKE_TIMEOUT')
902
850
class TestStateManagerPassToQueueManager(Base):
903
851
"""All queue events should go to QueueManager."""