openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #25699
Re: [Merge] lp:~alisonken1/openlp/error-strings-fix into lp:openlp
Review: Needs Fixing
Diff comments:
> === 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-19 22:43:53 +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-19 22:43:53 +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,22 @@
> # 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 saved source text matches projector
> + """
> + # GIVEN: Record entries in database
> + item = self.projector.get_projector_by_ip(TEST1_DATA.ip)
> + if item is None:
If this is a test then you should know if item is none.
Should this be a second test, Not for now but have up your sleeve!
> + self.projector.add_projector(TEST1_DATA)
> + item = self.projector.get_projector_by_id(TEST1_DATA.id)
> + item_id = item.id
is this needed?
> + source = ProjectorSource(projector_id=item_id, code='11', text='First RGB source')
> + self.projector.add_source(source)
> +
> + # WHEN: Retrieve the projector item
> + item = self.projector.get_projector_by_id(item_id)
> +
> + # THEN: Projector should have the same source entry
> + self.assertTrue(compare_source(item.source_list[0], source))
>
--
https://code.launchpad.net/~alisonken1/openlp/error-strings-fix/+merge/246957
Your team OpenLP Core is subscribed to branch lp:openlp.
Follow ups
References