~nataliabidart/ubuntuone-client/use-sso-qt

« back to all changes in this revision

Viewing changes to tests/syncdaemon/test_states.py

  • Committer: Natalia B. Bidart
  • Date: 2012-02-22 20:50:31 UTC
  • mfrom: (1193.1.3 ubuntuone-client)
  • Revision ID: natalia.bidart@canonical.com-20120222205031-kxwlj8fxzykyvrw1
MergedĀ trunkĀ in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
847
847
            self.assertFalse(self.aq.queue.active)
848
848
 
849
849
 
850
 
class TestStateManagerPassToNetworkManager(Base):
851
 
    """All network events should go to NetworkManager."""
852
 
 
853
 
    @defer.inlineCallbacks
854
 
    def setUp(self):
855
 
        yield super(TestStateManagerPassToNetworkManager,
856
 
                    self).setUp()
857
 
 
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)
864
 
            orig_on_event(event)
865
 
        self.sm.connection.on_event = fake_on_event
866
 
 
867
 
    def _test(self, event):
868
 
        """Generic test method."""
869
 
        cnt = 0
870
 
        for node in self.sm_nodes_ok:
871
 
            cnt += 1
872
 
            self.sm.state = node
873
 
            self.sm.handle_default(event)
874
 
            self.assertEqual(self.called_events, [event]*cnt)
875
 
 
876
 
    def test_net_connected(self):
877
 
        """SYS_NET_CONNECTED should go to Connection no matter where."""
878
 
        self._test('SYS_NET_CONNECTED')
879
 
 
880
 
    def test_user_connect(self):
881
 
        """SYS_USER_CONNECT should go to Connection no matter where."""
882
 
        self._test('SYS_USER_CONNECT')
883
 
 
884
 
    def test_net_disconnected(self):
885
 
        """SYS_NET_DISCONNECTED should go to Connection no matter where."""
886
 
        self._test('SYS_NET_DISCONNECTED')
887
 
 
888
 
    def test_user_disconnect(self):
889
 
        """SYS_USER_DISCONNECT should go to Connection no matter where."""
890
 
        self._test('SYS_USER_DISCONNECT')
891
 
 
892
 
    def test_connection_lost(self):
893
 
        """SYS_CONNECTION_LOST should go to Connection no matter where."""
894
 
        self._test('SYS_CONNECTION_LOST')
895
 
 
896
 
    def test_handshake_timeout(self):
897
 
        """SYS_HANDSHAKE_TIMEOUT should go to Connection no matter where."""
898
 
        self._test('SYS_HANDSHAKE_TIMEOUT')
899
 
 
900
 
 
901
 
 
902
850
class TestStateManagerPassToQueueManager(Base):
903
851
    """All queue events should go to QueueManager."""
904
852