From d1bd72a508e0b6fb5d2cbe70d61d5fd6b91ef147 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Mon, 21 Jan 2013 15:04:18 +0200 Subject: [PATCH] Add a test for Jonathan to complete. --- tests/functional/openlp_core_lib/test_lib.py | 21 +++++++++++++++++++ .../openlp_core_ui/test_starttimedialog.py | 3 +++ 2 files changed, 24 insertions(+) diff --git a/tests/functional/openlp_core_lib/test_lib.py b/tests/functional/openlp_core_lib/test_lib.py index de2847ac5..cb6d68d62 100644 --- a/tests/functional/openlp_core_lib/test_lib.py +++ b/tests/functional/openlp_core_lib/test_lib.py @@ -298,4 +298,25 @@ class TestLib(TestCase): MockedQtGui.QMessageBox.information.assert_called_with(u'parent', u'mocked translate', 'message') assert not result, u'The result should be False' + def validate_thumb_file_exists_test(self): + """ + Test the validate_thumb() function when a file exists + """ + # GIVEN: A mocked out os module, functions rigged to work for us, and fake paths to a file and a thumb + with patch(u'openlp.core.lib.os') as mocked_os: + file_path = u'path/to/file' + thumb_path = u'path/to/thumb' + file_mocked_stat = MagicMock() + file_mocked_stat.st_mtime = datetime.now() + thumb_mocked_stat = MagicMock() + thumb_mocked_stat.st_mtime = datetime.now() + timedelta(seconds=10) + mocked_os.path.exists.return_value = True + mocked_os.stat.side_effect = { + file_path: file_mocked_stat, + thumb_path: thumb_mocked_stat + } + # WHEN: we run the validate_thumb() function + + # THEN: we should have called a few functions, and the result should be True + mocked_os.path.exists.assert_called_with(file_path) diff --git a/tests/functional/openlp_core_ui/test_starttimedialog.py b/tests/functional/openlp_core_ui/test_starttimedialog.py index f36852b62..0aed81592 100644 --- a/tests/functional/openlp_core_ui/test_starttimedialog.py +++ b/tests/functional/openlp_core_ui/test_starttimedialog.py @@ -20,6 +20,9 @@ class TestStartTimeDialog(TestCase): self.form = starttimeform.StartTimeForm(self.window) def tearDown(self): + """ + Delete all the C++ objects at the end so that we don't have a segfault + """ del self.form del self.window del self.app