← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~alisonken1/openlp/error-strings-fix into lp:openlp

 

Ken Roberts has proposed merging lp:~alisonken1/openlp/error-strings-fix into lp:openlp.

Requested reviews:
  Tim Bentley (trb143)

For more details, see:
https://code.launchpad.net/~alisonken1/openlp/error-strings-fix/+merge/247032

Remove translations for error code number to string.
Refactored source text test

lp:~alisonken1/openlp/error-strings-fix (revision 2481)
[SUCCESS] http://ci.openlp.org/job/Branch-01-Pull/884/
[SUCCESS] http://ci.openlp.org/job/Branch-02-Functional-Tests/816/
[SUCCESS] http://ci.openlp.org/job/Branch-03-Interface-Tests/762/
[SUCCESS] http://ci.openlp.org/job/Branch-04a-Windows_Functional_Tests/673/
[SUCCESS] http://ci.openlp.org/job/Branch-04b-Windows_Interface_Tests/272/
[SUCCESS] http://ci.openlp.org/job/Branch-05a-Code_Analysis/421/
[SUCCESS] http://ci.openlp.org/job/Branch-05b-Test_Coverage/292/

-- 
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/projector/constants.py'
--- openlp/core/lib/projector/constants.py	2015-01-18 13:39:21 +0000
+++ openlp/core/lib/projector/constants.py	2015-01-20 15:53:07 +0000
@@ -153,72 +153,66 @@
                  'ERR2': E_PARAMETER,        # Invalid parameter error
                  'ERR3': E_UNAVAILABLE,      # Projector busy
                  'ERR4': E_PROJECTOR,        # Projector or display failure
-                 E_AUTHENTICATION: translate('OpenLP.ProjectorConstants', 'ERRA'),
-                 E_UNDEFINED: translate('OpenLP.ProjectorConstants', 'ERR1'),
-                 E_PARAMETER: translate('OpenLP.ProjectorConstants', 'ERR2'),
-                 E_UNAVAILABLE: translate('OpenLP.ProjectorConstants', 'ERR3'),
-                 E_PROJECTOR: translate('OpenLP.ProjectorConstants', 'ERR4')}
+                 E_AUTHENTICATION: 'ERRA',
+                 E_UNDEFINED: 'ERR1',
+                 E_PARAMETER: 'ERR2',
+                 E_UNAVAILABLE: 'ERR3',
+                 E_PROJECTOR: 'ERR4'}
 
 # Map error/status codes to string
-ERROR_STRING = {0: translate('OpenLP.ProjectorConstants', 'S_OK'),
-                E_GENERAL: translate('OpenLP.ProjectorConstants', 'E_GENERAL'),
-                E_NOT_CONNECTED: translate('OpenLP.ProjectorConstants', 'E_NOT_CONNECTED'),
-                E_FAN: translate('OpenLP.ProjectorConstants', 'E_FAN'),
-                E_LAMP: translate('OpenLP.ProjectorConstants', 'E_LAMP'),
-                E_TEMP: translate('OpenLP.ProjectorConstants', 'E_TEMP'),
-                E_COVER: translate('OpenLP.ProjectorConstants', 'E_COVER'),
-                E_FILTER: translate('OpenLP.ProjectorConstants', 'E_FILTER'),
-                E_AUTHENTICATION: translate('OpenLP.ProjectorConstants', 'E_AUTHENTICATION'),
-                E_NO_AUTHENTICATION: translate('OpenLP.ProjectorConstants', 'E_NO_AUTHENTICATION'),
-                E_UNDEFINED: translate('OpenLP.ProjectorConstants', 'E_UNDEFINED'),
-                E_PARAMETER: translate('OpenLP.ProjectorConstants', 'E_PARAMETER'),
-                E_UNAVAILABLE: translate('OpenLP.ProjectorConstants', 'E_UNAVAILABLE'),
-                E_PROJECTOR: translate('OpenLP.ProjectorConstants', 'E_PROJECTOR'),
-                E_INVALID_DATA: translate('OpenLP.ProjectorConstants', 'E_INVALID_DATA'),
-                E_WARN: translate('OpenLP.ProjectorConstants', 'E_WARN'),
-                E_ERROR: translate('OpenLP.ProjectorConstants', 'E_ERROR'),
-                E_CLASS: translate('OpenLP.ProjectorConstants', 'E_CLASS'),
-                E_PREFIX: translate('OpenLP.ProjectorConstants', 'E_PREFIX'),  # Last projector error
-                E_CONNECTION_REFUSED: translate('OpenLP.ProjectorConstants',
-                                                'E_CONNECTION_REFUSED'),  # First QtSocket error
-                E_REMOTE_HOST_CLOSED_CONNECTION: translate('OpenLP.ProjectorConstants',
-                                                           'E_REMOTE_HOST_CLOSED_CONNECTION'),
-                E_HOST_NOT_FOUND: translate('OpenLP.ProjectorConstants', 'E_HOST_NOT_FOUND'),
-                E_SOCKET_ACCESS: translate('OpenLP.ProjectorConstants', 'E_SOCKET_ACCESS'),
-                E_SOCKET_RESOURCE: translate('OpenLP.ProjectorConstants', 'E_SOCKET_RESOURCE'),
-                E_SOCKET_TIMEOUT: translate('OpenLP.ProjectorConstants', 'E_SOCKET_TIMEOUT'),
-                E_DATAGRAM_TOO_LARGE: translate('OpenLP.ProjectorConstants', 'E_DATAGRAM_TOO_LARGE'),
-                E_NETWORK: translate('OpenLP.ProjectorConstants', 'E_NETWORK'),
-                E_ADDRESS_IN_USE: translate('OpenLP.ProjectorConstants', 'E_ADDRESS_IN_USE'),
-                E_SOCKET_ADDRESS_NOT_AVAILABLE: translate('OpenLP.ProjectorConstants',
-                                                          'E_SOCKET_ADDRESS_NOT_AVAILABLE'),
-                E_UNSUPPORTED_SOCKET_OPERATION: translate('OpenLP.ProjectorConstants',
-                                                          'E_UNSUPPORTED_SOCKET_OPERATION'),
-                E_PROXY_AUTHENTICATION_REQUIRED: translate('OpenLP.ProjectorConstants',
-                                                           'E_PROXY_AUTHENTICATION_REQUIRED'),
-                E_SLS_HANDSHAKE_FAILED: translate('OpenLP.ProjectorConstants', 'E_SLS_HANDSHAKE_FAILED'),
-                E_UNFINISHED_SOCKET_OPERATION: translate('OpenLP.ProjectorConstants',
-                                                         'E_UNFINISHED_SOCKET_OPERATION'),
-                E_PROXY_CONNECTION_REFUSED: translate('OpenLP.ProjectorConstants', 'E_PROXY_CONNECTION_REFUSED'),
-                E_PROXY_CONNECTION_CLOSED: translate('OpenLP.ProjectorConstants', 'E_PROXY_CONNECTION_CLOSED'),
-                E_PROXY_CONNECTION_TIMEOUT: translate('OpenLP.ProjectorConstants', 'E_PROXY_CONNECTION_TIMEOUT'),
-                E_PROXY_NOT_FOUND: translate('OpenLP.ProjectorConstants', 'E_PROXY_NOT_FOUND'),
-                E_PROXY_PROTOCOL: translate('OpenLP.ProjectorConstants', 'E_PROXY_PROTOCOL'),
-                E_UNKNOWN_SOCKET_ERROR: translate('OpenLP.ProjectorConstants', 'E_UNKNOWN_SOCKET_ERROR')}
+ERROR_STRING = {0: 'S_OK',
+                E_GENERAL: 'E_GENERAL',
+                E_NOT_CONNECTED: 'E_NOT_CONNECTED',
+                E_FAN: 'E_FAN',
+                E_LAMP: 'E_LAMP',
+                E_TEMP: 'E_TEMP',
+                E_COVER: 'E_COVER',
+                E_FILTER: 'E_FILTER',
+                E_AUTHENTICATION: 'E_AUTHENTICATION',
+                E_NO_AUTHENTICATION: 'E_NO_AUTHENTICATION',
+                E_UNDEFINED: 'E_UNDEFINED',
+                E_PARAMETER: 'E_PARAMETER',
+                E_UNAVAILABLE: 'E_UNAVAILABLE',
+                E_PROJECTOR: 'E_PROJECTOR',
+                E_INVALID_DATA: 'E_INVALID_DATA',
+                E_WARN: 'E_WARN',
+                E_ERROR: 'E_ERROR',
+                E_CLASS: 'E_CLASS',
+                E_PREFIX: 'E_PREFIX',  # Last projector error
+                E_CONNECTION_REFUSED: 'E_CONNECTION_REFUSED',  # First QtSocket error
+                E_REMOTE_HOST_CLOSED_CONNECTION: 'E_REMOTE_HOST_CLOSED_CONNECTION',
+                E_HOST_NOT_FOUND: 'E_HOST_NOT_FOUND',
+                E_SOCKET_ACCESS: 'E_SOCKET_ACCESS',
+                E_SOCKET_RESOURCE: 'E_SOCKET_RESOURCE',
+                E_SOCKET_TIMEOUT: 'E_SOCKET_TIMEOUT',
+                E_DATAGRAM_TOO_LARGE: 'E_DATAGRAM_TOO_LARGE',
+                E_NETWORK: 'E_NETWORK',
+                E_ADDRESS_IN_USE: 'E_ADDRESS_IN_USE',
+                E_SOCKET_ADDRESS_NOT_AVAILABLE: 'E_SOCKET_ADDRESS_NOT_AVAILABLE',
+                E_UNSUPPORTED_SOCKET_OPERATION: 'E_UNSUPPORTED_SOCKET_OPERATION',
+                E_PROXY_AUTHENTICATION_REQUIRED: 'E_PROXY_AUTHENTICATION_REQUIRED',
+                E_SLS_HANDSHAKE_FAILED: 'E_SLS_HANDSHAKE_FAILED',
+                E_UNFINISHED_SOCKET_OPERATION: 'E_UNFINISHED_SOCKET_OPERATION',
+                E_PROXY_CONNECTION_REFUSED: 'E_PROXY_CONNECTION_REFUSED',
+                E_PROXY_CONNECTION_CLOSED: 'E_PROXY_CONNECTION_CLOSED',
+                E_PROXY_CONNECTION_TIMEOUT: 'E_PROXY_CONNECTION_TIMEOUT',
+                E_PROXY_NOT_FOUND: 'E_PROXY_NOT_FOUND',
+                E_PROXY_PROTOCOL: 'E_PROXY_PROTOCOL',
+                E_UNKNOWN_SOCKET_ERROR: 'E_UNKNOWN_SOCKET_ERROR'}
 
-STATUS_STRING = {S_NOT_CONNECTED: translate('OpenLP.ProjectorConstants', 'S_NOT_CONNECTED'),
-                 S_CONNECTING: translate('OpenLP.ProjectorConstants', 'S_CONNECTING'),
-                 S_CONNECTED: translate('OpenLP.ProjectorConstants', 'S_CONNECTED'),
-                 S_STATUS: translate('OpenLP.ProjectorConstants', 'S_STATUS'),
-                 S_OFF: translate('OpenLP.ProjectorConstants', 'S_OFF'),
-                 S_INITIALIZE: translate('OpenLP.ProjectorConstants', 'S_INITIALIZE'),
-                 S_STANDBY: translate('OpenLP.ProjectorConstants', 'S_STANDBY'),
-                 S_WARMUP: translate('OpenLP.ProjectorConstants', 'S_WARMUP'),
-                 S_ON: translate('OpenLP.ProjectorConstants', 'S_ON'),
-                 S_COOLDOWN: translate('OpenLP.ProjectorConstants', 'S_COOLDOWN'),
-                 S_INFO: translate('OpenLP.ProjectorConstants', 'S_INFO'),
-                 S_NETWORK_SENDING: translate('OpenLP.ProjectorConstants', 'S_NETWORK_SENDING'),
-                 S_NETWORK_RECEIVED: translate('OpenLP.ProjectorConstants', 'S_NETWORK_RECEIVED')}
+STATUS_STRING = {S_NOT_CONNECTED: 'S_NOT_CONNECTED',
+                 S_CONNECTING: 'S_CONNECTING',
+                 S_CONNECTED: 'S_CONNECTED',
+                 S_STATUS: 'S_STATUS',
+                 S_OFF: 'S_OFF',
+                 S_INITIALIZE: 'S_INITIALIZE',
+                 S_STANDBY: 'S_STANDBY',
+                 S_WARMUP: 'S_WARMUP',
+                 S_ON: 'S_ON',
+                 S_COOLDOWN: 'S_COOLDOWN',
+                 S_INFO: 'S_INFO',
+                 S_NETWORK_SENDING: 'S_NETWORK_SENDING',
+                 S_NETWORK_RECEIVED: 'S_NETWORK_RECEIVED'}
 
 # Map error/status codes to message strings
 ERROR_MSG = {E_OK: translate('OpenLP.ProjectorConstants', 'OK'),  # E_OK | S_OK

=== modified file 'tests/functional/openlp_core_lib/test_projectordb.py'
--- tests/functional/openlp_core_lib/test_projectordb.py	2015-01-18 13:39:21 +0000
+++ tests/functional/openlp_core_lib/test_projectordb.py	2015-01-20 15:53:07 +0000
@@ -29,7 +29,7 @@
 from unittest import TestCase
 from tests.functional import MagicMock, patch
 
-from openlp.core.lib.projector.db import Projector, ProjectorDB
+from openlp.core.lib.projector.db import Projector, ProjectorDB, ProjectorSource
 
 from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA
 
@@ -49,6 +49,17 @@
         one.notes == two.notes
 
 
+def compare_source(one, two):
+    """
+    Verify two ProjectorSource instances contain the same data
+    """
+    return one is not None and \
+        two is not None and \
+        one.projector_id == two.projector_id and \
+        one.code == two.code and \
+        one.text == two.text
+
+
 def add_records(self, test):
     """
     Add record if not in database
@@ -151,3 +162,20 @@
         # THEN: Record ID should remain the same, but data should be changed
         self.assertEqual(record_id, record.id, 'Edited record should have the same ID')
         self.assertTrue(compare_data(TEST3_DATA, record), 'Edited record should have new data')
+
+    def source_add_test(self):
+        """
+        Test source entry for projector item
+        """
+        # GIVEN: Record entries in database
+        self.projector.add_projector(TEST1_DATA)
+        item = self.projector.get_projector_by_id(TEST1_DATA.id)
+        item_id = item.id
+
+        # WHEN: A source entry is saved for item
+        source = ProjectorSource(projector_id=item_id, code='11', text='First RGB source')
+        self.projector.add_source(source)
+
+        # THEN: Projector should have the same source entry
+        item = self.projector.get_projector_by_id(item_id)
+        self.assertTrue(compare_source(item.source_list[0], source))


Follow ups