← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~alisonken1/openlp/bug-1409627 into lp:openlp

 

Ken Roberts has proposed merging lp:~alisonken1/openlp/bug-1409627 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/bug-1409627/+merge/246343

Fix First Time Wizard fail on URL error (ex: proxy authorization)

lp:~alisonken1/openlp/bug-1409627 (revision 2475)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/862/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/794/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/740/
[FAILURE] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/644/
Stopping after failure

Passed local pep8
passed local nosetest
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~alisonken1/openlp/bug-1409627 into lp:openlp.
=== modified file 'openlp/core/ui/firsttimeform.py'
--- openlp/core/ui/firsttimeform.py	2014-12-31 10:58:13 +0000
+++ openlp/core/ui/firsttimeform.py	2015-01-13 19:11:49 +0000
@@ -182,7 +182,18 @@
         self.config = ConfigParser()
         user_agent = 'OpenLP/' + Registry().get('application').applicationVersion()
         self.application.process_events()
-        web_config = get_web_page('%s%s' % (self.web, 'download.cfg'), header=('User-Agent', user_agent))
+        try:
+            web_config = get_web_page('%s%s' % (self.web, 'download.cfg'), header=('User-Agent', user_agent))
+        except (urllib.error.URLError, ConnectionError) as err:
+            msg = QtGui.QMessageBox()
+            title = translate('OpenLP.FirstTimeWizard', 'Network Error')
+            msg.setText('{} {}'.format(title, err.code if hasattr(err, 'code') else ''))
+            msg.setInformativeText(translate('OpenLP.FirstTimeWizard',
+                                             'There was a network error attempting to\n'
+                                             'connect to retrieve initial configuration inforamtion'))
+            msg.setStandardButtons(msg.Ok)
+            ans = msg.exec_()
+            web_config = False
         if web_config:
             files = web_config.read()
             try:

=== modified file 'tests/functional/openlp_core_ui/test_firsttimeform.py'
--- tests/functional/openlp_core_ui/test_firsttimeform.py	2015-01-11 19:46:41 +0000
+++ tests/functional/openlp_core_ui/test_firsttimeform.py	2015-01-13 19:11:49 +0000
@@ -30,6 +30,7 @@
 Package to test the openlp.core.ui.firsttimeform package.
 """
 import os
+import urllib
 from unittest import TestCase
 
 from openlp.core.common import Registry
@@ -214,3 +215,24 @@
 
             # THEN: The First Time Form should not have web access
             self.assertFalse(first_time_form.web_access, 'There should not be web access with an invalid config file')
+
+    @patch('openlp.core.ui.firsttimeform.get_web_page')
+    @patch('openlp.core.ui.firsttimeform.QtGui.QMessageBox')
+    def network_error_test(self, mocked_message_box, mocked_get_web_page):
+        """
+        Test we catch a network error in First Time Wizard - bug 1409627
+        """
+        # GIVEN: Initial setup and mocks
+        first_time_form = FirstTimeForm(None)
+        first_time_form.initialize(MagicMock())
+        mocked_get_web_page.side_effect = urllib.error.HTTPError(url='http//localhost',
+                                                                 code=407,
+                                                                 msg='Network proxy error',
+                                                                 hdrs=None,
+                                                                 fp=None)
+        # WHEN: the First Time Wizard calls to get the initial configuration
+        first_time_form._download_index()
+
+        # THEN: the critical_error_message_box should have been called
+        self.assertEquals(mocked_message_box.mock_calls[1][1][0], 'Network Error 407',
+                          'first_time_form should have caught Network Error')


Follow ups