Fix a validation bug with presentations being loaded from services

Fix range bug stopping service items being triggered unless it was the first!

bzr-revno: 2389
This commit is contained in:
Tim Bentley 2014-06-08 18:55:06 +01:00
commit 8d67406728
2 changed files with 23 additions and 5 deletions

View File

@ -401,6 +401,9 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
:param suffix_list: New Suffix's to be supported
"""
if isinstance(suffix_list, str):
self.suffixes.append(suffix_list)
else:
for suffix in suffix_list:
if suffix not in self.suffixes:
self.suffixes.append(suffix)
@ -1081,6 +1084,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
:param field:
:param message: The data passed in from a remove message
"""
self.log_debug(message)
self.set_item(int(message))
def set_item(self, index):
@ -1089,7 +1093,7 @@ class ServiceManager(OpenLPMixin, RegistryMixin, QtGui.QWidget, Ui_ServiceManage
:param index: The index of the service item list to be actioned.
"""
if 0 >= index < self.service_manager_list.topLevelItemCount():
if 0 <= index < self.service_manager_list.topLevelItemCount():
item = self.service_manager_list.topLevelItem(index)
self.service_manager_list.setCurrentItem(item)
self.make_live()

View File

@ -71,7 +71,21 @@ class TestServiceManager(TestCase):
service_manager._save_lite = False
service_manager.service_theme = 'test_theme'
service = service_manager.create_basic_service()[0]
# THEN: The the controller should be registered in the registry.
# THEN: The controller should be registered in the registry.
self.assertNotEqual(service, None, 'The base service should be created')
self.assertEqual(service['openlp_core']['service-theme'], 'test_theme', 'The test theme should be saved')
self.assertEqual(service['openlp_core']['lite-service'], False, 'The lite service should be saved')
def supported_suffixes_test(self):
"""
Test the create basic service array
"""
# GIVEN: A new service manager instance.
service_manager = ServiceManager(None)
# WHEN: a suffix is added as an individual or a list.
service_manager.supported_suffixes('txt')
service_manager.supported_suffixes(['pptx', 'ppt'])
# THEN: The suffixes should be available to test.
self.assertEqual('txt' in service_manager.suffixes, True, 'The suffix txt should be in the list')
self.assertEqual('ppt' in service_manager.suffixes, True, 'The suffix ppt should be in the list')
self.assertEqual('pptx' in service_manager.suffixes, True, 'The suffix pptx should be in the list')