~mvo/ubuntu-sso-client/strawman-lp711413

« back to all changes in this revision

Viewing changes to ubuntu_sso/main/tests/test_linux.py

  • Committer: Michael Vogt
  • Date: 2012-05-23 14:57:43 UTC
  • Revision ID: michael.vogt@ubuntu.com-20120523145743-tkzrd6u5mc0zgnhu
ensure that the timeout trigger the normal exception

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
 
48
48
 
49
49
    def test_retry_on_race_lp711413(self):
50
 
        """ test the retry on dbus failure feature to fix bug #711413 """
 
50
        """Test the retry on dbus failure feature to fix bug #711413 """
51
51
        def _simulate_dbus_unavailable_once():
52
52
            """ helper to simulate a dbus not-yet-ready error once """
53
53
            patcher.stop()
65
65
        self.assertNotEqual(bus, None)
66
66
        self.assertTrue(delay > 1*DBUS_RETRY_WAIT_TIME and
67
67
                        delay < 2*DBUS_RETRY_WAIT_TIME)
 
68
 
 
69
    
 
70
    @patch("time.sleep")
 
71
    @patch("dbus.SessionBus")
 
72
    def test_raise_on_timeout(self, mock_session_bus, mock_sleep):
 
73
        """Test that  the normal dbus.DBusException is raised on timeout """
 
74
        def _raise_dbus_exception():
 
75
            raise dbus.DBusException()
 
76
        mock_session_bus.side_effect = _raise_dbus_exception
 
77
        proxy = UbuntuSSOProxy(None)
 
78
        self.assertRaises(dbus.DBusException, lambda: proxy.bus)
 
79