From fb2de75cbcb2129608f21703649fc04619a2ed24 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Tue, 5 Apr 2016 20:11:10 +0100 Subject: [PATCH] fix tests --- .../test_webpagereader.py} | 34 +++++++++---------- .../functional/openlp_core_utils/__init__.py | 21 ------------ .../test_utils.py | 0 .../interfaces/openlp_core_utils/__init__.py | 21 ------------ 4 files changed, 17 insertions(+), 59 deletions(-) rename tests/functional/{openlp_core_utils/test_utils.py => openlp_core_lib/test_webpagereader.py} (88%) delete mode 100644 tests/functional/openlp_core_utils/__init__.py rename tests/interfaces/{openlp_core_utils => openlp_core_common}/test_utils.py (100%) delete mode 100644 tests/interfaces/openlp_core_utils/__init__.py diff --git a/tests/functional/openlp_core_utils/test_utils.py b/tests/functional/openlp_core_lib/test_webpagereader.py similarity index 88% rename from tests/functional/openlp_core_utils/test_utils.py rename to tests/functional/openlp_core_lib/test_webpagereader.py index c5c14378a..772c8c562 100644 --- a/tests/functional/openlp_core_utils/test_utils.py +++ b/tests/functional/openlp_core_lib/test_webpagereader.py @@ -37,7 +37,7 @@ class TestUtils(TestCase): """ Test that getting a user agent on Linux returns a user agent suitable for Linux """ - with patch('openlp.core.utils.sys') as mocked_sys: + with patch('openlp.core.lib.sys') as mocked_sys: # GIVEN: The system is Linux mocked_sys.platform = 'linux2' @@ -53,7 +53,7 @@ class TestUtils(TestCase): """ Test that getting a user agent on Windows returns a user agent suitable for Windows """ - with patch('openlp.core.utils.sys') as mocked_sys: + with patch('openlp.core.lib.sys') as mocked_sys: # GIVEN: The system is Linux mocked_sys.platform = 'win32' @@ -68,7 +68,7 @@ class TestUtils(TestCase): """ Test that getting a user agent on OS X returns a user agent suitable for OS X """ - with patch('openlp.core.utils.sys') as mocked_sys: + with patch('openlp.core.lib.sys') as mocked_sys: # GIVEN: The system is Linux mocked_sys.platform = 'darwin' @@ -83,7 +83,7 @@ class TestUtils(TestCase): """ Test that getting a user agent on a non-Linux/Windows/OS X platform returns the default user agent """ - with patch('openlp.core.utils.sys') as mocked_sys: + with patch('openlp.core.lib.sys') as mocked_sys: # GIVEN: The system is Linux mocked_sys.platform = 'freebsd' @@ -111,9 +111,9 @@ class TestUtils(TestCase): """ Test that the get_web_page method works correctly """ - with patch('openlp.core.utils.urllib.request.Request') as MockRequest, \ - patch('openlp.core.utils.urllib.request.urlopen') as mock_urlopen, \ - patch('openlp.core.utils._get_user_agent') as mock_get_user_agent, \ + with patch('openlp.core.lib.urllib.request.Request') as MockRequest, \ + patch('openlp.core.lib.urllib.request.urlopen') as mock_urlopen, \ + patch('openlp.core.lib.webpagereader._get_user_agent') as mock_get_user_agent, \ patch('openlp.core.common.Registry') as MockRegistry: # GIVEN: Mocked out objects and a fake URL mocked_request_object = MagicMock() @@ -141,9 +141,9 @@ class TestUtils(TestCase): """ Test that adding a header to the call to get_web_page() adds the header to the request """ - with patch('openlp.core.utils.urllib.request.Request') as MockRequest, \ - patch('openlp.core.utils.urllib.request.urlopen') as mock_urlopen, \ - patch('openlp.core.utils._get_user_agent') as mock_get_user_agent: + with patch('openlp.core.lib.urllib.request.Request') as MockRequest, \ + patch('openlp.core.lib.urllib.request.urlopen') as mock_urlopen, \ + patch('openlp.core.lib.webpagereader._get_user_agent') as mock_get_user_agent: # GIVEN: Mocked out objects, a fake URL and a fake header mocked_request_object = MagicMock() MockRequest.return_value = mocked_request_object @@ -170,9 +170,9 @@ class TestUtils(TestCase): """ Test that adding a user agent in the header when calling get_web_page() adds that user agent to the request """ - with patch('openlp.core.utils.urllib.request.Request') as MockRequest, \ - patch('openlp.core.utils.urllib.request.urlopen') as mock_urlopen, \ - patch('openlp.core.utils._get_user_agent') as mock_get_user_agent: + with patch('openlp.core.lib.urllib.request.Request') as MockRequest, \ + patch('openlp.core.lib.urllib.request.urlopen') as mock_urlopen, \ + patch('openlp.core.lib.webpagereader._get_user_agent') as mock_get_user_agent: # GIVEN: Mocked out objects, a fake URL and a fake header mocked_request_object = MagicMock() MockRequest.return_value = mocked_request_object @@ -198,10 +198,10 @@ class TestUtils(TestCase): """ Test that passing "update_openlp" as true to get_web_page calls Registry().get('app').process_events() """ - with patch('openlp.core.utils.urllib.request.Request') as MockRequest, \ - patch('openlp.core.utils.urllib.request.urlopen') as mock_urlopen, \ - patch('openlp.core.utils._get_user_agent') as mock_get_user_agent, \ - patch('openlp.core.utils.Registry') as MockRegistry: + with patch('openlp.core.lib.urllib.request.Request') as MockRequest, \ + patch('openlp.core.lib.urllib.request.urlopen') as mock_urlopen, \ + patch('openlp.core.lib.webpagereader._get_user_agent') as mock_get_user_agent, \ + patch('openlp.core.lib.Registry') as MockRegistry: # GIVEN: Mocked out objects, a fake URL mocked_request_object = MagicMock() MockRequest.return_value = mocked_request_object diff --git a/tests/functional/openlp_core_utils/__init__.py b/tests/functional/openlp_core_utils/__init__.py deleted file mode 100644 index 02bded5b0..000000000 --- a/tests/functional/openlp_core_utils/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2016 OpenLP Developers # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### diff --git a/tests/interfaces/openlp_core_utils/test_utils.py b/tests/interfaces/openlp_core_common/test_utils.py similarity index 100% rename from tests/interfaces/openlp_core_utils/test_utils.py rename to tests/interfaces/openlp_core_common/test_utils.py diff --git a/tests/interfaces/openlp_core_utils/__init__.py b/tests/interfaces/openlp_core_utils/__init__.py deleted file mode 100644 index 02bded5b0..000000000 --- a/tests/interfaces/openlp_core_utils/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2016 OpenLP Developers # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -###############################################################################