From c24fb0cb59b917e8dfb3572e3b10bab69d5dbf07 Mon Sep 17 00:00:00 2001 From: Tim Bentley Date: Sun, 2 Dec 2018 08:39:53 +0000 Subject: [PATCH] Fix tests and code --- openlp/core/ui/media/__init__.py | 33 ------------------- openlp/core/ui/media/mediacontroller.py | 1 - .../openlp_core/lib/test_serviceitem.py | 6 +++- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/openlp/core/ui/media/__init__.py b/openlp/core/ui/media/__init__.py index 26601a1f3..d60046a16 100644 --- a/openlp/core/ui/media/__init__.py +++ b/openlp/core/ui/media/__init__.py @@ -69,39 +69,6 @@ class ItemMediaInfo(object): media_type = MediaType() -# def get_media_players(): -# """ -# This method extracts the configured media players and overridden player -# from the settings. -# """ -# log.debug('get_media_players') -# saved_players = Settings().value('media/players') -# reg_ex = QtCore.QRegExp(r'.*\[(.*)\].*') -# if Settings().value('media/override player') == QtCore.Qt.Checked: -# if reg_ex.exactMatch(saved_players): -# overridden_player = '{text}'.format(text=reg_ex.cap(1)) -# else: -# overridden_player = 'auto' -# else: -# overridden_player = '' -# saved_players_list = saved_players.replace('[', '').replace(']', '').split(',') if saved_players else [] -# return saved_players_list, overridden_player - - -# def set_media_players(players_list, overridden_player='auto'): -# """ -# This method saves the configured media players and overridden player to the settings -# -# :param players_list: A list with all active media players. -# :param overridden_player: Here an special media player is chosen for all media actions. -# """ -# log.debug('set_media_players') -# players = ','.join(players_list) -# if Settings().value('media/override player') == QtCore.Qt.Checked and overridden_player != 'auto': -# players = players.replace(overridden_player, '[{text}]'.format(text=overridden_player)) -# Settings().setValue('media/players', players) - - def parse_optical_path(input_string): """ Split the optical path info. diff --git a/openlp/core/ui/media/mediacontroller.py b/openlp/core/ui/media/mediacontroller.py index f1de8fb78..83bd1be8d 100644 --- a/openlp/core/ui/media/mediacontroller.py +++ b/openlp/core/ui/media/mediacontroller.py @@ -138,7 +138,6 @@ class MediaController(RegistryBase, LogMixin, RegistryProperties): Registry().register_function('songs_hide', self.media_hide) Registry().register_function('songs_blank', self.media_blank) Registry().register_function('songs_unblank', self.media_unblank) - # Registry().register_function('mediaitem_media_rebuild', self._set_active_players) Registry().register_function('mediaitem_suffixes', self._generate_extensions_lists) register_endpoint(media_endpoint) diff --git a/tests/functional/openlp_core/lib/test_serviceitem.py b/tests/functional/openlp_core/lib/test_serviceitem.py index b860ea790..f590ed4de 100644 --- a/tests/functional/openlp_core/lib/test_serviceitem.py +++ b/tests/functional/openlp_core/lib/test_serviceitem.py @@ -26,6 +26,7 @@ import os from unittest import TestCase from unittest.mock import MagicMock, patch +from openlp.core.state import State from openlp.core.common import md5_hash from openlp.core.common.path import Path from openlp.core.common.registry import Registry @@ -110,8 +111,11 @@ class TestServiceItem(TestCase, TestMixin): service_item.add_icon = MagicMock() FormattingTags.load_tags() - # WHEN: We add a custom from a saved service + # WHEN: We add a custom from a saved serviceand set the media state line = convert_file_service_item(TEST_PATH, 'serviceitem_custom_1.osj') + State().add_service("media", 0) + State().update_pre_conditions("media", True) + State().flush_preconditions() service_item.set_from_service(line) # THEN: We should get back a valid service item