X-Git-Url: http://git.maemo.org/git/?p=gc-dialer;a=blobdiff_plain;f=tests%2Ftest_startup.py;h=a469626fbf4a9756e95079bf0e95281cc5d37be3;hp=88d8807b35b42d0c881e0c87125872757f229634;hb=24d388f15cd9a1d6079134c1679d463785a741f9;hpb=df2936c8cf055a4c3268a34f01746c64975f3f8e diff --git a/tests/test_startup.py b/tests/test_startup.py index 88d8807..a469626 100644 --- a/tests/test_startup.py +++ b/tests/test_startup.py @@ -11,28 +11,45 @@ sys.path.append("../src") import dc_glade -def test_startup_with_no_data_dir(): +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_startup_with_no_data_dir_with_dummy_hildon(): dc_glade.Dialcentral._data_path = os.path.join(os.path.dirname(__file__), "notexistent_data") dc_glade.Dialcentral._user_settings = "%s/settings.ini" % dc_glade.Dialcentral._data_path try: - handle = dc_glade.Dialcentral() - 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 + sys.path.insert(0, "dummy_hildon") + startup(dc_glade.Dialcentral) + sys.path.remove("dummy_hildon") + finally: + os.remove(dc_glade.Dialcentral._user_settings) + os.removedirs(dc_glade.Dialcentral._data_path) - with test_utils.expected(RuntimeError("Login Failed")): - handle.refresh_session() - handle._save_settings() +def test_startup_with_no_data_dir(): + dc_glade.Dialcentral._data_path = os.path.join(os.path.dirname(__file__), "notexistent_data") + dc_glade.Dialcentral._user_settings = "%s/settings.ini" % dc_glade.Dialcentral._data_path - del handle + try: + startup(dc_glade.Dialcentral) finally: os.remove(dc_glade.Dialcentral._user_settings) os.removedirs(dc_glade.Dialcentral._data_path) @@ -43,25 +60,7 @@ def test_startup_with_empty_data_dir(): dc_glade.Dialcentral._user_settings = "%s/settings.ini" % dc_glade.Dialcentral._data_path try: - os.makedirs(dc_glade.Dialcentral._data_path) - - handle = dc_glade.Dialcentral() - 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 + startup(dc_glade.Dialcentral) finally: os.remove(dc_glade.Dialcentral._user_settings) os.removedirs(dc_glade.Dialcentral._data_path) @@ -71,20 +70,4 @@ def test_startup_with_basic_data_dir(): dc_glade.Dialcentral._data_path = os.path.join(os.path.dirname(__file__), "basic_data") dc_glade.Dialcentral._user_settings = "%s/settings.ini" % dc_glade.Dialcentral._data_path - handle = dc_glade.Dialcentral() - 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 + startup(dc_glade.Dialcentral)