Merge lp:~raoul-snyman/openlp/qsize-2.4 into lp:openlp/2.4

Proposed by Raoul Snyman
Status: Merged
Merged at revision: 2661
Proposed branch: lp:~raoul-snyman/openlp/qsize-2.4
Merge into: lp:openlp/2.4
Diff against target: 189 lines (+95/-15)
3 files modified
openlp/core/ui/projector/sourceselectform.py (+6/-7)
tests/functional/openlp_core_ui/test_projector_sourceselectform.py (+83/-0)
tests/interfaces/openlp_core_ui/test_projectorsourceform.py (+6/-8)
To merge this branch: bzr merge lp:~raoul-snyman/openlp/qsize-2.4
Reviewer Review Type Date Requested Status
Tomas Groth Approve
Review via email: mp+313345@code.launchpad.net

This proposal supersedes a proposal from 2016-12-15.

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/ui/projector/sourceselectform.py'
2--- openlp/core/ui/projector/sourceselectform.py 2016-08-12 09:23:56 +0000
3+++ openlp/core/ui/projector/sourceselectform.py 2016-12-15 11:23:06 +0000
4@@ -61,9 +61,8 @@
5 """
6 groupdict = {}
7 keydict = {}
8- checklist = inputs
9- key = checklist[0][0]
10- for item in checklist:
11+ key = inputs[0][0]
12+ for item in inputs:
13 if item[0] == key:
14 groupdict[item] = source_text[item]
15 continue
16@@ -75,7 +74,7 @@
17 return keydict
18
19
20-def Build_Tab(group, source_key, default, projector, projectordb, edit=False):
21+def build_tab(group, source_key, default, projector, projectordb, edit=False):
22 """
23 Create the radio button page for a tab.
24 Dictionary will be a 1-key entry where key=tab to setup, val=list of inputs.
25@@ -174,7 +173,7 @@
26 :param width: Remove default width parameter in kwargs
27 :param height: Remove default height parameter in kwargs
28 """
29- self.tabSize = QtWidgets.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
30+ self.tabSize = QtCore.QSize(kwargs.pop('width', 100), kwargs.pop('height', 25))
31 QtWidgets.QTabBar.__init__(self, parent, *args, **kwargs)
32
33 def paintEvent(self, event):
34@@ -275,7 +274,7 @@
35 keys.sort()
36 if self.edit:
37 for key in keys:
38- (tab, button_count, buttonchecked) = Build_Tab(group=self.button_group,
39+ (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
40 source_key={key: self.source_group[key]},
41 default=self.projector.source,
42 projector=self.projector,
43@@ -290,7 +289,7 @@
44 QtWidgets.QDialogButtonBox.Cancel)
45 else:
46 for key in keys:
47- (tab, button_count, buttonchecked) = Build_Tab(group=self.button_group,
48+ (tab, button_count, buttonchecked) = build_tab(group=self.button_group,
49 source_key={key: self.source_group[key]},
50 default=self.projector.source,
51 projector=self.projector,
52
53=== added file 'tests/functional/openlp_core_ui/test_projector_sourceselectform.py'
54--- tests/functional/openlp_core_ui/test_projector_sourceselectform.py 1970-01-01 00:00:00 +0000
55+++ tests/functional/openlp_core_ui/test_projector_sourceselectform.py 2016-12-15 11:23:06 +0000
56@@ -0,0 +1,83 @@
57+# -*- coding: utf-8 -*-
58+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
59+
60+###############################################################################
61+# OpenLP - Open Source Lyrics Projection #
62+# --------------------------------------------------------------------------- #
63+# Copyright (c) 2008-2016 OpenLP Developers #
64+# --------------------------------------------------------------------------- #
65+# This program is free software; you can redistribute it and/or modify it #
66+# under the terms of the GNU General Public License as published by the Free #
67+# Software Foundation; version 2 of the License. #
68+# #
69+# This program is distributed in the hope that it will be useful, but WITHOUT #
70+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
71+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
72+# more details. #
73+# #
74+# You should have received a copy of the GNU General Public License along #
75+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
76+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
77+###############################################################################
78+"""
79+:mod: `tests.functional.openlp_core_ui.test_projectorsourceform` module
80+
81+Tests for the Projector Source Select form.
82+"""
83+from PyQt5 import QtCore
84+
85+from openlp.core.ui.projector.sourceselectform import FingerTabBarWidget, source_group
86+
87+
88+def test_source_group():
89+ """
90+ Test the source_group() method
91+ """
92+ # GIVEN: A list of inputs and source text
93+ inputs = [
94+ 'vga1', 'vga2',
95+ 'hdmi1', 'hdmi2'
96+ ]
97+ source_text = {
98+ 'vga1': 'VGA 1',
99+ 'vga2': 'VGA 2',
100+ 'hdmi1': 'HDMI 1',
101+ 'hdmi2': 'HDMI 2'
102+ }
103+
104+ # WHEN: source_group() is called
105+ result = source_group(inputs, source_text)
106+
107+ # THEN: the resultant dictionary should be correct
108+ expected_dict = {
109+ 'v': {'vga1': 'VGA 1', 'vga2': 'VGA 2'},
110+ 'h': {'hdmi1': 'HDMI 1', 'hdmi2': 'HDMI 2'}
111+ }
112+ assert result == expected_dict, result
113+
114+
115+def test_finger_tab_bar_widget():
116+ """
117+ Test that the FingerTabBarWidget is initialised correctly
118+ """
119+ # GIVEN: A FinderTabBarWidget class
120+ # WHEN: An instance of the FingerTabBarWidget is created
121+ widget = FingerTabBarWidget()
122+
123+ # THEN: It should havea tabSize of 100x25
124+ assert widget.tabSize == QtCore.QSize(100, 25)
125+
126+
127+def test_finger_tab_bar_widget_with_kwargs():
128+ """
129+ Test that the FingerTabBarWidget is initialised correctly from kwargs
130+ """
131+ # GIVEN: A FinderTabBarWidget class and some arguments
132+ width = 300
133+ height = 100
134+
135+ # WHEN: An instance of the FingerTabBarWidget is created
136+ widget = FingerTabBarWidget(width=width, height=height)
137+
138+ # THEN: It should havea tabSize of 100x25
139+ assert widget.tabSize == QtCore.QSize(width, height)
140
141=== modified file 'tests/interfaces/openlp_core_ui/test_projectorsourceform.py'
142--- tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2016-01-15 19:41:14 +0000
143+++ tests/interfaces/openlp_core_ui/test_projectorsourceform.py 2016-12-15 11:23:06 +0000
144@@ -24,19 +24,17 @@
145
146 Tests for the Projector Source Select form.
147 """
148-import logging
149-log = logging.getLogger(__name__)
150-log.debug('test_projectorsourceform loaded')
151 import os
152+import time
153 from unittest import TestCase
154+from unittest.mock import patch
155
156 from PyQt5.QtWidgets import QDialog
157
158-from tests.functional import patch
159 from tests.helpers.testmixin import TestMixin
160 from tests.resources.projector.data import TEST_DB, TEST1_DATA
161
162-from openlp.core.common import Registry, Settings
163+from openlp.core.common import Registry
164 from openlp.core.lib.projector.db import ProjectorDB, Projector
165 from openlp.core.lib.projector.constants import PJLINK_DEFAULT_CODES, PJLINK_DEFAULT_SOURCES
166 from openlp.core.ui.projector.sourceselectform import source_group, SourceSelectSingle
167@@ -49,7 +47,7 @@
168 :returns: dictionary of valid PJLink source codes grouped by PJLink source group
169 """
170 test_group = {}
171- for group in PJLINK_DEFAULT_SOURCES.keys():
172+ for group in PJLINK_DEFAULT_SOURCES:
173 test_group[group] = {}
174 for key in PJLINK_DEFAULT_CODES:
175 test_group[key[0]][key] = PJLINK_DEFAULT_CODES[key]
176@@ -86,8 +84,8 @@
177 Delete all C++ objects at end so we don't segfault.
178 """
179 self.projectordb.session.close()
180- del(self.projectordb)
181- del(self.projector)
182+ del self.projectordb
183+ del self.projector
184 retries = 0
185 while retries < 5:
186 try:
187
188=== added file 'tests/resources/__init__.py'
189=== added file 'tests/resources/projector/__init__.py'

Subscribers

People subscribed via source and target branches

to all changes: