def startup(factory): handle = factory() with test_utils.expected(AssertionError("Attempting login before app is fully loaded")): handle.refresh_session() for i in xrange(10): if handle._initDone: print "Completed init on iteration %d" % i break time.sleep(1) assert handle._initDone with test_utils.expected(RuntimeError("Login Failed")): handle.refresh_session() handle._save_settings() del handle
def test_not_logged_in(): correctUsername, correctPassword = "", "" MockBrowserModule = generate_mock(False, correctUsername, correctPassword) gv_backend.browser_emu, RealBrowser = MockBrowserModule, gv_backend.browser_emu try: backend = gv_backend.GVDialer() assert not backend.is_authed() assert not backend.login("bad_name", "bad_password") backend.logout() with test_utils.expected(RuntimeError): backend.dial("5551234567") with test_utils.expected(RuntimeError): backend.send_sms("5551234567", "Hello World") assert backend.get_account_number() == "", "%s" % backend.get_account_number() assert backend.get_callback_number() == "" with test_utils.expected(Exception): recent = list(backend.get_recent()) with test_utils.expected(Exception): messages = list(backend.get_messages()) finally: gv_backend.browser_emu = RealBrowser