Merge lp:~alisonken1/openlp/strings-plugins4 into lp:openlp

Proposed by Ken Roberts
Status: Merged
Approved by: Raoul Snyman
Approved revision: 2670
Merged at revision: 2671
Proposed branch: lp:~alisonken1/openlp/strings-plugins4
Merge into: lp:openlp
Diff against target: 184 lines (+89/-16)
3 files modified
openlp/core/lib/projector/pjlink1.py (+3/-1)
openlp/plugins/songusage/forms/songusagedetailform.py (+12/-9)
tests/functional/openlp_core_lib/test_projector_pjlink1.py (+74/-6)
To merge this branch: bzr merge lp:~alisonken1/openlp/strings-plugins4
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tomas Groth Approve
Review via email: mp+295991@code.launchpad.net

Commit message

Convert strings in plugins part 4

Description of the change

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/core/lib/projector/pjlink1.py'
2--- openlp/core/lib/projector/pjlink1.py 2016-04-16 21:32:56 +0000
3+++ openlp/core/lib/projector/pjlink1.py 2016-05-28 06:11:20 +0000
4@@ -58,7 +58,7 @@
5
6 PJLINK_PREFIX = '%'
7 PJLINK_CLASS = '1'
8-PJLINK_HEADER = '%s%s' % (PJLINK_PREFIX, PJLINK_CLASS)
9+PJLINK_HEADER = '{prefix}{linkclass}'.format(prefix=PJLINK_PREFIX, linkclass=PJLINK_CLASS)
10 PJLINK_SUFFIX = CR
11
12
13@@ -160,8 +160,10 @@
14 self.source = None
15 self.other_info = None
16 if hasattr(self, 'timer'):
17+ log.debug('({ip}): Calling timer.stop()'.format(ip=self.ip))
18 self.timer.stop()
19 if hasattr(self, 'socket_timer'):
20+ log.debug('({ip}): Calling socket_timer.stop()'.format(ip=self.ip))
21 self.socket_timer.stop()
22 self.send_queue = []
23 self.send_busy = False
24
25=== modified file 'openlp/plugins/songusage/forms/songusagedetailform.py'
26--- openlp/plugins/songusage/forms/songusagedetailform.py 2016-01-09 16:26:14 +0000
27+++ openlp/plugins/songusage/forms/songusagedetailform.py 2016-05-28 06:11:20 +0000
28@@ -81,9 +81,10 @@
29 )
30 return
31 check_directory_exists(path)
32- file_name = translate('SongUsagePlugin.SongUsageDetailForm', 'usage_detail_%s_%s.txt') % \
33- (self.from_date_calendar.selectedDate().toString('ddMMyyyy'),
34- self.to_date_calendar.selectedDate().toString('ddMMyyyy'))
35+ file_name = translate('SongUsagePlugin.SongUsageDetailForm',
36+ 'usage_detail_{old}_{new}.txt'
37+ ).format(old=self.from_date_calendar.selectedDate().toString('ddMMyyyy'),
38+ new=self.to_date_calendar.selectedDate().toString('ddMMyyyy'))
39 Settings().setValue(self.plugin.settings_section + '/from date', self.from_date_calendar.selectedDate())
40 Settings().setValue(self.plugin.settings_section + '/to date', self.to_date_calendar.selectedDate())
41 usage = self.plugin.manager.get_all_objects(
42@@ -95,21 +96,23 @@
43 try:
44 file_handle = open(report_file_name, 'wb')
45 for instance in usage:
46- record = '\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",\"%s\",' \
47- '\"%s\",\"%s\"\n' % \
48- (instance.usagedate, instance.usagetime, instance.title, instance.copyright,
49- instance.ccl_number, instance.authors, instance.plugin_name, instance.source)
50+ record = ('\"{date}\",\"{time}\",\"{title}\",\"{copyright}\",\"{ccli}\",\"{authors}\",'
51+ '\"{name}\",\"{source}\"\n').format(date=instance.usagedate, time=instance.usagetime,
52+ title=instance.title, copyright=instance.copyright,
53+ ccli=instance.ccl_number, authors=instance.authors,
54+ name=instance.plugin_name, source=instance.source)
55 file_handle.write(record.encode('utf-8'))
56 self.main_window.information_message(
57 translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation'),
58 translate('SongUsagePlugin.SongUsageDetailForm',
59- 'Report \n%s \nhas been successfully created. ') % report_file_name
60+ 'Report \n{name} \nhas been successfully created. ').format(name=report_file_name)
61 )
62 except OSError as ose:
63 log.exception('Failed to write out song usage records')
64 critical_error_message_box(translate('SongUsagePlugin.SongUsageDetailForm', 'Report Creation Failed'),
65 translate('SongUsagePlugin.SongUsageDetailForm',
66- 'An error occurred while creating the report: %s') % ose.strerror)
67+ 'An error occurred while creating the report: {error}'
68+ ).format(error=ose.strerror))
69 finally:
70 if file_handle:
71 file_handle.close()
72
73=== modified file 'tests/functional/openlp_core_lib/test_projector_pjlink1.py'
74--- tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-05-21 18:19:18 +0000
75+++ tests/functional/openlp_core_lib/test_projector_pjlink1.py 2016-05-28 06:11:20 +0000
76@@ -35,6 +35,20 @@
77 pjlink_test = PJLink1(name='test', ip='127.0.0.1', pin=TEST_PIN, no_poll=True)
78
79
80+class DummyTimer(object):
81+ '''
82+ Dummy class to fake timers
83+ '''
84+ def __init__(self, *args, **kwargs):
85+ pass
86+
87+ def start(self, *args, **kwargs):
88+ pass
89+
90+ def stop(self, *args, **kwargs):
91+ pass
92+
93+
94 class TestPJLink(TestCase):
95 """
96 Tests for the PJLink module
97@@ -43,13 +57,10 @@
98 @patch.object(pjlink_test, 'send_command')
99 @patch.object(pjlink_test, 'waitForReadyRead')
100 @patch('openlp.core.common.qmd5_hash')
101- def authenticated_connection_call_test(self,
102- mock_qmd5_hash,
103- mock_waitForReadyRead,
104- mock_send_command,
105+ def authenticated_connection_call_test(self, mock_qmd5_hash, mock_waitForReadyRead, mock_send_command,
106 mock_readyRead):
107 """
108- Fix for projector connect with PJLink authentication exception. Ticket 92187.
109+ Ticket 92187: Fix for projector connect with PJLink authentication exception.
110 """
111 # GIVEN: Test object
112 pjlink = pjlink_test
113@@ -63,9 +74,23 @@
114 self.assertTrue(mock_qmd5_hash.called_with(TEST_PIN,
115 "Connection request should have been called with TEST_PIN"))
116
117+ def projector_class_test(self):
118+ """
119+ Test class version from projector
120+ """
121+ # GIVEN: Test object
122+ pjlink = pjlink_test
123+
124+ # WHEN: Process class response
125+ pjlink.process_clss('1')
126+
127+ # THEN: Projector class should be set to 1
128+ self.assertEquals(pjlink.pjlink_class, '1',
129+ 'Projector should have returned class=1')
130+
131 def non_standard_class_reply_test(self):
132 """
133- bugfix 1550891 - CLSS request returns non-standard 'Class N' reply
134+ Bugfix 1550891: CLSS request returns non-standard 'Class N' reply
135 """
136 # GIVEN: Test object
137 pjlink = pjlink_test
138@@ -264,3 +289,46 @@
139
140 # THEN: Input selected should reflect current input
141 self.assertEquals(pjlink.source, '1', 'Input source should be set to "1"')
142+
143+ def projector_reset_information_test(self):
144+ """
145+ Test reset_information() resets all information and stops timers
146+ """
147+ # GIVEN: Test object and test data
148+ pjlink = pjlink_test
149+ pjlink.power = S_ON
150+ pjlink.pjlink_name = 'OPENLPTEST'
151+ pjlink.manufacturer = 'PJLINK'
152+ pjlink.model = '1'
153+ pjlink.shutter = True
154+ pjlink.mute = True
155+ pjlink.lamp = True
156+ pjlink.fan = True
157+ pjlink.source_available = True
158+ pjlink.other_info = 'ANOTHER TEST'
159+ pjlink.send_queue = True
160+ pjlink.send_busy = True
161+ pjlink.timer = DummyTimer()
162+ pjlink.socket_timer = DummyTimer()
163+
164+ # WHEN: reset_information() is called
165+ with patch.object(pjlink.timer, 'stop') as mock_timer:
166+ with patch.object(pjlink.socket_timer, 'stop') as mock_socket_timer:
167+ pjlink.reset_information()
168+
169+ # THEN: All information should be reset and timers stopped
170+ self.assertEquals(pjlink.power, S_OFF, 'Projector power should be OFF')
171+ self.assertIsNone(pjlink.pjlink_name, 'Projector pjlink_name should be None')
172+ self.assertIsNone(pjlink.manufacturer, 'Projector manufacturer should be None')
173+ self.assertIsNone(pjlink.model, 'Projector model should be None')
174+ self.assertIsNone(pjlink.shutter, 'Projector shutter should be None')
175+ self.assertIsNone(pjlink.mute, 'Projector shuttter should be None')
176+ self.assertIsNone(pjlink.lamp, 'Projector lamp should be None')
177+ self.assertIsNone(pjlink.fan, 'Projector fan should be None')
178+ self.assertIsNone(pjlink.source_available, 'Projector source_available should be None')
179+ self.assertIsNone(pjlink.source, 'Projector source should be None')
180+ self.assertIsNone(pjlink.other_info, 'Projector other_info should be None')
181+ self.assertEquals(pjlink.send_queue, [], 'Projector send_queue should be an empty list')
182+ self.assertFalse(pjlink.send_busy, 'Projector send_busy should be False')
183+ self.assertTrue(mock_timer.called, 'Projector timer.stop() should have been called')
184+ self.assertTrue(mock_socket_timer.called, 'Projector socket_timer.stop() should have been called')