~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 15:04:13 UTC
  • Revision ID: michael.vogt@ubuntu.com-20120523150413-i08yyfpuie12ra01
refactor to simply the code, move the DBUS_RETRY_WAIT_TIME/DBUS_RETRY_COUNT_MAX into UbuntuSSOProxyTestCase

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
from ubuntu_sso.tests import TestCase
38
38
from ubuntu_sso.main import UbuntuSSOProxy
39
 
from ubuntu_sso.main.linux import DBUS_RETRY_WAIT_TIME
40
39
 
41
40
# because we are using twisted we have java like names C0103
42
41
# pylint: disable=C0103
63
62
        delay = time.time() - now
64
63
        # verify that we have a bus and that it took the expected time
65
64
        self.assertNotEqual(bus, None)
66
 
        self.assertTrue(delay > 1*DBUS_RETRY_WAIT_TIME and
67
 
                        delay < 2*DBUS_RETRY_WAIT_TIME)
 
65
        self.assertTrue(delay > 1*proxy.DBUS_RETRY_WAIT_TIME and
 
66
                        delay < 2*proxy.DBUS_RETRY_WAIT_TIME)
68
67
 
69
68
    
70
69
    @patch("time.sleep")
74
73
        def _raise_dbus_exception():
75
74
            raise dbus.DBusException()
76
75
        mock_session_bus.side_effect = _raise_dbus_exception
77
 
        proxy = UbuntuSSOProxy(None)
78
 
        self.assertRaises(dbus.DBusException, lambda: proxy.bus)
 
76
        self.assertRaises(dbus.DBusException, UbuntuSSOProxy, None)
79
77