Skip to content
Snippets Groups Projects
Commit ec223256 authored by Harry Saunders's avatar Harry Saunders
Browse files

Add tests for if load/save exits early

The tests ensure that .is_loading and .is_saving are reset if the
load/save functions exit early.
parent 773c54f2
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,10 @@ def fake_window_finding_function():
return []
def _raise(exception):
raise exception
@start_qapplication
class ProjectTest(unittest.TestCase):
def setUp(self):
......@@ -189,6 +193,31 @@ class ProjectTest(unittest.TestCase):
self.project._save()
self.assertEqual(self.project._offer_large_size_confirmation.call_count, 0)
def test_is_loading_is_False_after_error_thrown_during_load(self):
with mock.patch.object(self.project, '_load_file_dialog', lambda: _raise(IOError)):
try:
self.project.load()
except IOError:
pass
self.assertFalse(self.project.is_loading)
def test_is_loading_is_False_after_None_returned_from_load_dialog(self):
# None is returned from the load dialog when a user clicks Cancel
with mock.patch.object(self.project, '_load_file_dialog', lambda: None):
try:
self.project.load()
except IOError:
pass
self.assertFalse(self.project.is_loading)
def test_is_saving_is_False_if_error_thrown_during_save(self):
with mock.patch.object(self.project, '_get_project_size', lambda x: _raise(IOError)):
try:
self.project._save()
except IOError:
pass
self.assertFalse(self.project.is_saving)
if __name__ == "__main__":
unittest.main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment