Remove translations for error code number to string.

bzr-revno: 2480
This commit is contained in:
Ken Roberts 2015-01-21 19:14:09 +00:00 committed by Tim Bentley
commit 3c09f9468c
2 changed files with 86 additions and 64 deletions

View File

@ -153,72 +153,66 @@ PJLINK_ERRORS = {'ERRA': E_AUTHENTICATION, # Authentication error
'ERR2': E_PARAMETER, # Invalid parameter error 'ERR2': E_PARAMETER, # Invalid parameter error
'ERR3': E_UNAVAILABLE, # Projector busy 'ERR3': E_UNAVAILABLE, # Projector busy
'ERR4': E_PROJECTOR, # Projector or display failure 'ERR4': E_PROJECTOR, # Projector or display failure
E_AUTHENTICATION: translate('OpenLP.ProjectorConstants', 'ERRA'), E_AUTHENTICATION: 'ERRA',
E_UNDEFINED: translate('OpenLP.ProjectorConstants', 'ERR1'), E_UNDEFINED: 'ERR1',
E_PARAMETER: translate('OpenLP.ProjectorConstants', 'ERR2'), E_PARAMETER: 'ERR2',
E_UNAVAILABLE: translate('OpenLP.ProjectorConstants', 'ERR3'), E_UNAVAILABLE: 'ERR3',
E_PROJECTOR: translate('OpenLP.ProjectorConstants', 'ERR4')} E_PROJECTOR: 'ERR4'}
# Map error/status codes to string # Map error/status codes to string
ERROR_STRING = {0: translate('OpenLP.ProjectorConstants', 'S_OK'), ERROR_STRING = {0: 'S_OK',
E_GENERAL: translate('OpenLP.ProjectorConstants', 'E_GENERAL'), E_GENERAL: 'E_GENERAL',
E_NOT_CONNECTED: translate('OpenLP.ProjectorConstants', 'E_NOT_CONNECTED'), E_NOT_CONNECTED: 'E_NOT_CONNECTED',
E_FAN: translate('OpenLP.ProjectorConstants', 'E_FAN'), E_FAN: 'E_FAN',
E_LAMP: translate('OpenLP.ProjectorConstants', 'E_LAMP'), E_LAMP: 'E_LAMP',
E_TEMP: translate('OpenLP.ProjectorConstants', 'E_TEMP'), E_TEMP: 'E_TEMP',
E_COVER: translate('OpenLP.ProjectorConstants', 'E_COVER'), E_COVER: 'E_COVER',
E_FILTER: translate('OpenLP.ProjectorConstants', 'E_FILTER'), E_FILTER: 'E_FILTER',
E_AUTHENTICATION: translate('OpenLP.ProjectorConstants', 'E_AUTHENTICATION'), E_AUTHENTICATION: 'E_AUTHENTICATION',
E_NO_AUTHENTICATION: translate('OpenLP.ProjectorConstants', 'E_NO_AUTHENTICATION'), E_NO_AUTHENTICATION: 'E_NO_AUTHENTICATION',
E_UNDEFINED: translate('OpenLP.ProjectorConstants', 'E_UNDEFINED'), E_UNDEFINED: 'E_UNDEFINED',
E_PARAMETER: translate('OpenLP.ProjectorConstants', 'E_PARAMETER'), E_PARAMETER: 'E_PARAMETER',
E_UNAVAILABLE: translate('OpenLP.ProjectorConstants', 'E_UNAVAILABLE'), E_UNAVAILABLE: 'E_UNAVAILABLE',
E_PROJECTOR: translate('OpenLP.ProjectorConstants', 'E_PROJECTOR'), E_PROJECTOR: 'E_PROJECTOR',
E_INVALID_DATA: translate('OpenLP.ProjectorConstants', 'E_INVALID_DATA'), E_INVALID_DATA: 'E_INVALID_DATA',
E_WARN: translate('OpenLP.ProjectorConstants', 'E_WARN'), E_WARN: 'E_WARN',
E_ERROR: translate('OpenLP.ProjectorConstants', 'E_ERROR'), E_ERROR: 'E_ERROR',
E_CLASS: translate('OpenLP.ProjectorConstants', 'E_CLASS'), E_CLASS: 'E_CLASS',
E_PREFIX: translate('OpenLP.ProjectorConstants', 'E_PREFIX'), # Last projector error E_PREFIX: 'E_PREFIX', # Last projector error
E_CONNECTION_REFUSED: translate('OpenLP.ProjectorConstants', E_CONNECTION_REFUSED: 'E_CONNECTION_REFUSED', # First QtSocket error
'E_CONNECTION_REFUSED'), # First QtSocket error E_REMOTE_HOST_CLOSED_CONNECTION: 'E_REMOTE_HOST_CLOSED_CONNECTION',
E_REMOTE_HOST_CLOSED_CONNECTION: translate('OpenLP.ProjectorConstants', E_HOST_NOT_FOUND: 'E_HOST_NOT_FOUND',
'E_REMOTE_HOST_CLOSED_CONNECTION'), E_SOCKET_ACCESS: 'E_SOCKET_ACCESS',
E_HOST_NOT_FOUND: translate('OpenLP.ProjectorConstants', 'E_HOST_NOT_FOUND'), E_SOCKET_RESOURCE: 'E_SOCKET_RESOURCE',
E_SOCKET_ACCESS: translate('OpenLP.ProjectorConstants', 'E_SOCKET_ACCESS'), E_SOCKET_TIMEOUT: 'E_SOCKET_TIMEOUT',
E_SOCKET_RESOURCE: translate('OpenLP.ProjectorConstants', 'E_SOCKET_RESOURCE'), E_DATAGRAM_TOO_LARGE: 'E_DATAGRAM_TOO_LARGE',
E_SOCKET_TIMEOUT: translate('OpenLP.ProjectorConstants', 'E_SOCKET_TIMEOUT'), E_NETWORK: 'E_NETWORK',
E_DATAGRAM_TOO_LARGE: translate('OpenLP.ProjectorConstants', 'E_DATAGRAM_TOO_LARGE'), E_ADDRESS_IN_USE: 'E_ADDRESS_IN_USE',
E_NETWORK: translate('OpenLP.ProjectorConstants', 'E_NETWORK'), E_SOCKET_ADDRESS_NOT_AVAILABLE: 'E_SOCKET_ADDRESS_NOT_AVAILABLE',
E_ADDRESS_IN_USE: translate('OpenLP.ProjectorConstants', 'E_ADDRESS_IN_USE'), E_UNSUPPORTED_SOCKET_OPERATION: 'E_UNSUPPORTED_SOCKET_OPERATION',
E_SOCKET_ADDRESS_NOT_AVAILABLE: translate('OpenLP.ProjectorConstants', E_PROXY_AUTHENTICATION_REQUIRED: 'E_PROXY_AUTHENTICATION_REQUIRED',
'E_SOCKET_ADDRESS_NOT_AVAILABLE'), E_SLS_HANDSHAKE_FAILED: 'E_SLS_HANDSHAKE_FAILED',
E_UNSUPPORTED_SOCKET_OPERATION: translate('OpenLP.ProjectorConstants', E_UNFINISHED_SOCKET_OPERATION: 'E_UNFINISHED_SOCKET_OPERATION',
'E_UNSUPPORTED_SOCKET_OPERATION'), E_PROXY_CONNECTION_REFUSED: 'E_PROXY_CONNECTION_REFUSED',
E_PROXY_AUTHENTICATION_REQUIRED: translate('OpenLP.ProjectorConstants', E_PROXY_CONNECTION_CLOSED: 'E_PROXY_CONNECTION_CLOSED',
'E_PROXY_AUTHENTICATION_REQUIRED'), E_PROXY_CONNECTION_TIMEOUT: 'E_PROXY_CONNECTION_TIMEOUT',
E_SLS_HANDSHAKE_FAILED: translate('OpenLP.ProjectorConstants', 'E_SLS_HANDSHAKE_FAILED'), E_PROXY_NOT_FOUND: 'E_PROXY_NOT_FOUND',
E_UNFINISHED_SOCKET_OPERATION: translate('OpenLP.ProjectorConstants', E_PROXY_PROTOCOL: 'E_PROXY_PROTOCOL',
'E_UNFINISHED_SOCKET_OPERATION'), E_UNKNOWN_SOCKET_ERROR: 'E_UNKNOWN_SOCKET_ERROR'}
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')}
STATUS_STRING = {S_NOT_CONNECTED: translate('OpenLP.ProjectorConstants', 'S_NOT_CONNECTED'), STATUS_STRING = {S_NOT_CONNECTED: 'S_NOT_CONNECTED',
S_CONNECTING: translate('OpenLP.ProjectorConstants', 'S_CONNECTING'), S_CONNECTING: 'S_CONNECTING',
S_CONNECTED: translate('OpenLP.ProjectorConstants', 'S_CONNECTED'), S_CONNECTED: 'S_CONNECTED',
S_STATUS: translate('OpenLP.ProjectorConstants', 'S_STATUS'), S_STATUS: 'S_STATUS',
S_OFF: translate('OpenLP.ProjectorConstants', 'S_OFF'), S_OFF: 'S_OFF',
S_INITIALIZE: translate('OpenLP.ProjectorConstants', 'S_INITIALIZE'), S_INITIALIZE: 'S_INITIALIZE',
S_STANDBY: translate('OpenLP.ProjectorConstants', 'S_STANDBY'), S_STANDBY: 'S_STANDBY',
S_WARMUP: translate('OpenLP.ProjectorConstants', 'S_WARMUP'), S_WARMUP: 'S_WARMUP',
S_ON: translate('OpenLP.ProjectorConstants', 'S_ON'), S_ON: 'S_ON',
S_COOLDOWN: translate('OpenLP.ProjectorConstants', 'S_COOLDOWN'), S_COOLDOWN: 'S_COOLDOWN',
S_INFO: translate('OpenLP.ProjectorConstants', 'S_INFO'), S_INFO: 'S_INFO',
S_NETWORK_SENDING: translate('OpenLP.ProjectorConstants', 'S_NETWORK_SENDING'), S_NETWORK_SENDING: 'S_NETWORK_SENDING',
S_NETWORK_RECEIVED: translate('OpenLP.ProjectorConstants', 'S_NETWORK_RECEIVED')} S_NETWORK_RECEIVED: 'S_NETWORK_RECEIVED'}
# Map error/status codes to message strings # Map error/status codes to message strings
ERROR_MSG = {E_OK: translate('OpenLP.ProjectorConstants', 'OK'), # E_OK | S_OK ERROR_MSG = {E_OK: translate('OpenLP.ProjectorConstants', 'OK'), # E_OK | S_OK

View File

@ -29,7 +29,7 @@ PREREQUISITE: add_record() and get_all() functions validated.
from unittest import TestCase from unittest import TestCase
from tests.functional import MagicMock, patch 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 from tests.resources.projector.data import TEST1_DATA, TEST2_DATA, TEST3_DATA
@ -49,6 +49,17 @@ def compare_data(one, two):
one.notes == two.notes 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): def add_records(self, test):
""" """
Add record if not in database Add record if not in database
@ -151,3 +162,20 @@ class TestProjectorDB(TestCase):
# THEN: Record ID should remain the same, but data should be changed # 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.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') 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))