1 from __future__ import with_statement
9 sys.path.append("../src")
14 def test_startup_with_no_data_dir():
15 dc_glade.Dialcentral._data_path = os.path.join(os.path.dirname(__file__), "notexistent_data")
16 dc_glade.Dialcentral._user_settings = "%s/settings.ini" % dc_glade.Dialcentral._data_path
19 handle = dc_glade.Dialcentral()
20 with test_utils.expected(AssertionError("Attempting login before app is fully loaded")):
21 handle.refresh_session()
25 print "Completed init on iteration %d" % i
28 assert handle._initDone
30 with test_utils.expected(RuntimeError("Login Failed")):
31 handle.refresh_session()
33 handle._save_settings()
37 os.remove(dc_glade.Dialcentral._user_settings)
38 os.removedirs(dc_glade.Dialcentral._data_path)
41 def test_startup_with_empty_data_dir():
42 dc_glade.Dialcentral._data_path = os.path.join(os.path.dirname(__file__), "empty_data")
43 dc_glade.Dialcentral._user_settings = "%s/settings.ini" % dc_glade.Dialcentral._data_path
46 os.makedirs(dc_glade.Dialcentral._data_path)
48 handle = dc_glade.Dialcentral()
49 with test_utils.expected(AssertionError("Attempting login before app is fully loaded")):
50 handle.refresh_session()
54 print "Completed init on iteration %d" % i
57 assert handle._initDone
59 with test_utils.expected(RuntimeError("Login Failed")):
60 handle.refresh_session()
62 handle._save_settings()
66 os.remove(dc_glade.Dialcentral._user_settings)
67 os.removedirs(dc_glade.Dialcentral._data_path)
70 def test_startup_with_basic_data_dir():
71 dc_glade.Dialcentral._data_path = os.path.join(os.path.dirname(__file__), "basic_data")
72 dc_glade.Dialcentral._user_settings = "%s/settings.ini" % dc_glade.Dialcentral._data_path
74 handle = dc_glade.Dialcentral()
75 with test_utils.expected(AssertionError("Attempting login before app is fully loaded")):
76 handle.refresh_session()
80 print "Completed init on iteration %d" % i
83 assert handle._initDone
85 with test_utils.expected(RuntimeError("Login Failed")):
86 handle.refresh_session()
88 handle._save_settings()