From 94e8b90c5d3679fed4aacf44b7dad6c7e7eacfed Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sat, 13 Jul 2013 17:33:32 +0100 Subject: [PATCH] Added first test --- openlp/core/utils/__init__.py | 4 +-- .../interfaces/openlp_core_utils/__init__.py | 0 .../openlp_core_utils/test_utils.py | 29 +++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 tests/interfaces/openlp_core_utils/__init__.py create mode 100644 tests/interfaces/openlp_core_utils/test_utils.py diff --git a/openlp/core/utils/__init__.py b/openlp/core/utils/__init__.py index fb06332f3..843849f63 100644 --- a/openlp/core/utils/__init__.py +++ b/openlp/core/utils/__init__.py @@ -253,10 +253,10 @@ def is_not_image_file(file_name): ``file_name`` File name to be checked. """ - if file_name.isEmpty(): + if not file_name: return True else: - formats = [fmt.lower() for fmt in QtGui.QImageReader.supportedImageFormats()] + formats = [unicode(fmt).lower() for fmt in QtGui.QImageReader.supportedImageFormats()] file_part, file_extension = os.path.splitext(unicode(file_name)) if file_extension[1:].lower() in formats and os.path.exists(file_name): return False diff --git a/tests/interfaces/openlp_core_utils/__init__.py b/tests/interfaces/openlp_core_utils/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/interfaces/openlp_core_utils/test_utils.py b/tests/interfaces/openlp_core_utils/test_utils.py new file mode 100644 index 000000000..b4b4c2bc9 --- /dev/null +++ b/tests/interfaces/openlp_core_utils/test_utils.py @@ -0,0 +1,29 @@ +""" +Functional tests to test the AppLocation class and related methods. +""" +from unittest import TestCase + +from mock import patch +from PyQt4 import QtCore + + +from openlp.core.utils import is_not_image_file +from tests.utils.constants import TEST_RESOURCES_PATH + + +class TestUtils(TestCase): + """ + A test suite to test out various methods around the Utils functions. + """ + def is_not_image_empty_test(self): + """ + Test the method handles an empty string + """ + # Given and empty string + file_name = "" + + # WHEN testing for it + result = is_not_image_file(file_name) + + # THEN the result is false + assert result is True, u'The missing file test should return True'