From 93fd4763837bbeedfea7238457b7ea0c9a023a6b Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Fri, 7 Dec 2012 21:08:28 +0200 Subject: [PATCH] Expanded the check_directory_exists() test. --- tests/functional/openlp_core_lib/test_lib_module.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_lib_module.py b/tests/functional/openlp_core_lib/test_lib_module.py index 835b36f35..a2ea57eed 100644 --- a/tests/functional/openlp_core_lib/test_lib_module.py +++ b/tests/functional/openlp_core_lib/test_lib_module.py @@ -143,3 +143,15 @@ class TestLibModule(TestCase): mocked_exists.assert_called_with(directory_to_check) mocked_makedirs.assert_called_with(directory_to_check) + # WHEN: os.path.exists raises an IOError + mocked_exists.side_effect = IOError() + check_directory_exists(directory_to_check) + + # THEN: We shouldn't get an exception though the mocked exists has been called + mocked_exists.assert_called_with(directory_to_check) + + # WHEN: Some other exception is raised + mocked_exists.side_effect = ValueError() + + # THEN: check_directory_exists raises an exception + self.assertRaises(ValueError, check_directory_exists, directory_to_check)