Merge lp:~raoul-snyman/openlp/bug-1533246 into lp:openlp
- bug-1533246
- Merge into trunk
Proposed by
Raoul Snyman
Status: | Merged |
---|---|
Merged at revision: | 2614 |
Proposed branch: | lp:~raoul-snyman/openlp/bug-1533246 |
Merge into: | lp:openlp |
Diff against target: |
327 lines (+189/-37) 3 files modified
openlp/core/common/settings.py (+15/-30) openlp/core/ui/shortcutlistform.py (+10/-2) tests/interfaces/openlp_core_ui/test_shortcutlistform.py (+164/-5) |
To merge this branch: | bzr merge lp:~raoul-snyman/openlp/bug-1533246 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
David Wales (community) | Approve | ||
Tim Bentley | Approve | ||
Review via email: mp+285229@code.launchpad.net |
This proposal supersedes a proposal from 2016-02-04.
Commit message
Description of the change
Fixed a problem with the shortcuts.
Also tried to make the alternate clear button on the shortcuts dialog a little less weird.
Add this to your merge proposal:
-------
lp:~raoul-snyman/openlp/bug-1533246 (revision 2616)
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[FAILURE] https:/
Stopping after failure
To post a comment you must log in.
Revision history for this message
David Wales (daviewales) wrote : Posted in a previous version of this proposal | # |
review:
Needs Fixing
Revision history for this message
Tim Bentley (trb143) : | # |
review:
Approve
Revision history for this message
David Wales (daviewales) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/common/settings.py' | |||
2 | --- openlp/core/common/settings.py 2016-01-10 16:01:43 +0000 | |||
3 | +++ openlp/core/common/settings.py 2016-02-05 19:02:39 +0000 | |||
4 | @@ -252,68 +252,56 @@ | |||
5 | 252 | 'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)], | 252 | 'shortcuts/blankScreen': [QtGui.QKeySequence(QtCore.Qt.Key_Period)], |
6 | 253 | 'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)], | 253 | 'shortcuts/collapse': [QtGui.QKeySequence(QtCore.Qt.Key_Minus)], |
7 | 254 | 'shortcuts/desktopScreen': [QtGui.QKeySequence(QtCore.Qt.Key_D)], | 254 | 'shortcuts/desktopScreen': [QtGui.QKeySequence(QtCore.Qt.Key_D)], |
10 | 255 | 'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), | 255 | 'shortcuts/delete': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], |
9 | 256 | QtGui.QKeySequence(QtCore.Qt.Key_Delete)], | ||
11 | 257 | 'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)], | 256 | 'shortcuts/down': [QtGui.QKeySequence(QtCore.Qt.Key_Down)], |
12 | 258 | 'shortcuts/editSong': [], | 257 | 'shortcuts/editSong': [], |
13 | 259 | 'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)], | 258 | 'shortcuts/escapeItem': [QtGui.QKeySequence(QtCore.Qt.Key_Escape)], |
14 | 260 | 'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)], | 259 | 'shortcuts/expand': [QtGui.QKeySequence(QtCore.Qt.Key_Plus)], |
15 | 261 | 'shortcuts/exportThemeItem': [], | 260 | 'shortcuts/exportThemeItem': [], |
26 | 262 | 'shortcuts/fileNewItem': [QtGui.QKeySequence(QtGui.QKeySequence.New), | 261 | 'shortcuts/fileNewItem': [QtGui.QKeySequence(QtGui.QKeySequence.New)], |
27 | 263 | QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_N)], | 262 | 'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(QtGui.QKeySequence.SaveAs)], |
28 | 264 | 'shortcuts/fileSaveAsItem': [QtGui.QKeySequence(QtGui.QKeySequence.SaveAs), | 263 | 'shortcuts/fileExitItem': [QtGui.QKeySequence(QtGui.QKeySequence.Quit)], |
29 | 265 | QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.SHIFT + QtCore.Qt.Key_S)], | 264 | 'shortcuts/fileSaveItem': [QtGui.QKeySequence(QtGui.QKeySequence.Save)], |
30 | 266 | 'shortcuts/fileExitItem': [QtGui.QKeySequence(QtGui.QKeySequence.Quit), | 265 | 'shortcuts/fileOpenItem': [QtGui.QKeySequence(QtGui.QKeySequence.Open)], |
21 | 267 | QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F4)], | ||
22 | 268 | 'shortcuts/fileSaveItem': [QtGui.QKeySequence(QtGui.QKeySequence.Save), | ||
23 | 269 | QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_S)], | ||
24 | 270 | 'shortcuts/fileOpenItem': [QtGui.QKeySequence(QtGui.QKeySequence.Open), | ||
25 | 271 | QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_O)], | ||
31 | 272 | 'shortcuts/goLive': [], | 266 | 'shortcuts/goLive': [], |
32 | 273 | 'shortcuts/importThemeItem': [], | 267 | 'shortcuts/importThemeItem': [], |
33 | 274 | 'shortcuts/importBibleItem': [], | 268 | 'shortcuts/importBibleItem': [], |
36 | 275 | 'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), | 269 | 'shortcuts/listViewBiblesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], |
35 | 276 | QtGui.QKeySequence(QtCore.Qt.Key_Delete)], | ||
37 | 277 | 'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), | 270 | 'shortcuts/listViewBiblesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), |
38 | 278 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], | 271 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], |
39 | 279 | 'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), | 272 | 'shortcuts/listViewBiblesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), |
40 | 280 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], | 273 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], |
41 | 281 | 'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), | 274 | 'shortcuts/listViewBiblesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), |
42 | 282 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], | 275 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], |
45 | 283 | 'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), | 276 | 'shortcuts/listViewCustomDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], |
44 | 284 | QtGui.QKeySequence(QtCore.Qt.Key_Delete)], | ||
46 | 285 | 'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), | 277 | 'shortcuts/listViewCustomPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), |
47 | 286 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], | 278 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], |
48 | 287 | 'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), | 279 | 'shortcuts/listViewCustomLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), |
49 | 288 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], | 280 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], |
50 | 289 | 'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), | 281 | 'shortcuts/listViewCustomServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), |
51 | 290 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], | 282 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], |
54 | 291 | 'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), | 283 | 'shortcuts/listViewImagesDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], |
53 | 292 | QtGui.QKeySequence(QtCore.Qt.Key_Delete)], | ||
55 | 293 | 'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), | 284 | 'shortcuts/listViewImagesPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), |
56 | 294 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], | 285 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], |
57 | 295 | 'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), | 286 | 'shortcuts/listViewImagesLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), |
58 | 296 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], | 287 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], |
59 | 297 | 'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), | 288 | 'shortcuts/listViewImagesServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), |
60 | 298 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], | 289 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], |
63 | 299 | 'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), | 290 | 'shortcuts/listViewMediaDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], |
62 | 300 | QtGui.QKeySequence(QtCore.Qt.Key_Delete)], | ||
64 | 301 | 'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), | 291 | 'shortcuts/listViewMediaPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), |
65 | 302 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], | 292 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], |
66 | 303 | 'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), | 293 | 'shortcuts/listViewMediaLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), |
67 | 304 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], | 294 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], |
68 | 305 | 'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), | 295 | 'shortcuts/listViewMediaServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), |
69 | 306 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], | 296 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], |
72 | 307 | 'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), | 297 | 'shortcuts/listViewPresentationsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], |
71 | 308 | QtGui.QKeySequence(QtCore.Qt.Key_Delete)], | ||
73 | 309 | 'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), | 298 | 'shortcuts/listViewPresentationsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), |
74 | 310 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], | 299 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], |
75 | 311 | 'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), | 300 | 'shortcuts/listViewPresentationsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), |
76 | 312 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], | 301 | QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Enter)], |
77 | 313 | 'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), | 302 | 'shortcuts/listViewPresentationsServiceItem': [QtGui.QKeySequence(QtCore.Qt.Key_Plus), |
78 | 314 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], | 303 | QtGui.QKeySequence(QtCore.Qt.Key_Equal)], |
81 | 315 | 'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete), | 304 | 'shortcuts/listViewSongsDeleteItem': [QtGui.QKeySequence(QtGui.QKeySequence.Delete)], |
80 | 316 | QtGui.QKeySequence(QtCore.Qt.Key_Delete)], | ||
82 | 317 | 'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), | 305 | 'shortcuts/listViewSongsPreviewItem': [QtGui.QKeySequence(QtCore.Qt.Key_Return), |
83 | 318 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], | 306 | QtGui.QKeySequence(QtCore.Qt.Key_Enter)], |
84 | 319 | 'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), | 307 | 'shortcuts/listViewSongsLiveItem': [QtGui.QKeySequence(QtCore.Qt.SHIFT + QtCore.Qt.Key_Return), |
85 | @@ -337,8 +325,7 @@ | |||
86 | 337 | 'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)], | 325 | 'shortcuts/nextService': [QtGui.QKeySequence(QtCore.Qt.Key_Right)], |
87 | 338 | 'shortcuts/newService': [], | 326 | 'shortcuts/newService': [], |
88 | 339 | 'shortcuts/offlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)], | 327 | 'shortcuts/offlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)], |
91 | 340 | 'shortcuts/onlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents), | 328 | 'shortcuts/onlineHelpItem': [QtGui.QKeySequence(QtGui.QKeySequence.HelpContents)], |
90 | 341 | QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F1)], | ||
92 | 342 | 'shortcuts/openService': [], | 329 | 'shortcuts/openService': [], |
93 | 343 | 'shortcuts/saveService': [], | 330 | 'shortcuts/saveService': [], |
94 | 344 | 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), | 331 | 'shortcuts/previousItem_live': [QtGui.QKeySequence(QtCore.Qt.Key_Up), |
95 | @@ -351,12 +338,10 @@ | |||
96 | 351 | 'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)], | 338 | 'shortcuts/previousService': [QtGui.QKeySequence(QtCore.Qt.Key_Left)], |
97 | 352 | 'shortcuts/previousItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Up), | 339 | 'shortcuts/previousItem_preview': [QtGui.QKeySequence(QtCore.Qt.Key_Up), |
98 | 353 | QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], | 340 | QtGui.QKeySequence(QtCore.Qt.Key_PageUp)], |
101 | 354 | 'shortcuts/printServiceItem': [QtGui.QKeySequence(QtGui.QKeySequence.Print), | 341 | 'shortcuts/printServiceItem': [QtGui.QKeySequence(QtGui.QKeySequence.Print)], |
100 | 355 | QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_P)], | ||
102 | 356 | 'shortcuts/songExportItem': [], | 342 | 'shortcuts/songExportItem': [], |
103 | 357 | 'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)], | 343 | 'shortcuts/songUsageStatus': [QtGui.QKeySequence(QtCore.Qt.Key_F4)], |
106 | 358 | 'shortcuts/searchShortcut': [QtGui.QKeySequence(QtGui.QKeySequence.Find), | 344 | 'shortcuts/searchShortcut': [QtGui.QKeySequence(QtGui.QKeySequence.Find)], |
105 | 359 | QtGui.QKeySequence(QtCore.Qt.CTRL + QtCore.Qt.Key_F)], | ||
107 | 360 | 'shortcuts/settingsShortcutsItem': [], | 345 | 'shortcuts/settingsShortcutsItem': [], |
108 | 361 | 'shortcuts/settingsImportItem': [], | 346 | 'shortcuts/settingsImportItem': [], |
109 | 362 | 'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F7)], | 347 | 'shortcuts/settingsPluginListItem': [QtGui.QKeySequence(QtCore.Qt.ALT + QtCore.Qt.Key_F7)], |
110 | 363 | 348 | ||
111 | === modified file 'openlp/core/ui/shortcutlistform.py' | |||
112 | --- openlp/core/ui/shortcutlistform.py 2016-01-09 16:26:14 +0000 | |||
113 | +++ openlp/core/ui/shortcutlistform.py 2016-02-05 19:02:39 +0000 | |||
114 | @@ -320,9 +320,17 @@ | |||
115 | 320 | """ | 320 | """ |
116 | 321 | if not toggled: | 321 | if not toggled: |
117 | 322 | return | 322 | return |
120 | 323 | self.on_primary_push_button_clicked(False) | 323 | action = self._current_item_action() |
121 | 324 | self.on_alternate_push_button_clicked(False) | 324 | shortcuts = self._action_shortcuts(action) |
122 | 325 | self.refresh_shortcut_list() | 325 | self.refresh_shortcut_list() |
123 | 326 | primary_button_text = '' | ||
124 | 327 | alternate_button_text = '' | ||
125 | 328 | if shortcuts: | ||
126 | 329 | primary_button_text = self.get_shortcut_string(shortcuts[0], for_display=True) | ||
127 | 330 | if len(shortcuts) == 2: | ||
128 | 331 | alternate_button_text = self.get_shortcut_string(shortcuts[1], for_display=True) | ||
129 | 332 | self.primary_push_button.setText(primary_button_text) | ||
130 | 333 | self.alternate_push_button.setText(alternate_button_text) | ||
131 | 326 | 334 | ||
132 | 327 | def save(self): | 335 | def save(self): |
133 | 328 | """ | 336 | """ |
134 | 329 | 337 | ||
135 | === modified file 'tests/interfaces/openlp_core_ui/test_shortcutlistform.py' | |||
136 | --- tests/interfaces/openlp_core_ui/test_shortcutlistform.py 2015-12-31 22:46:06 +0000 | |||
137 | +++ tests/interfaces/openlp_core_ui/test_shortcutlistform.py 2016-02-05 19:02:39 +0000 | |||
138 | @@ -24,11 +24,12 @@ | |||
139 | 24 | """ | 24 | """ |
140 | 25 | from unittest import TestCase | 25 | from unittest import TestCase |
141 | 26 | 26 | ||
143 | 27 | from PyQt5 import QtWidgets | 27 | from PyQt5 import QtCore, QtGui, QtWidgets |
144 | 28 | 28 | ||
145 | 29 | from openlp.core.common import Registry | 29 | from openlp.core.common import Registry |
146 | 30 | from openlp.core.ui.shortcutlistform import ShortcutListForm | 30 | from openlp.core.ui.shortcutlistform import ShortcutListForm |
148 | 31 | from tests.interfaces import patch | 31 | |
149 | 32 | from tests.interfaces import MagicMock, patch | ||
150 | 32 | from tests.helpers.testmixin import TestMixin | 33 | from tests.helpers.testmixin import TestMixin |
151 | 33 | 34 | ||
152 | 34 | 35 | ||
153 | @@ -59,13 +60,171 @@ | |||
154 | 59 | button = QtWidgets.QPushButton() | 60 | button = QtWidgets.QPushButton() |
155 | 60 | checked = True | 61 | checked = True |
156 | 61 | enabled = True | 62 | enabled = True |
158 | 62 | text = "new!" | 63 | text = 'new!' |
159 | 63 | 64 | ||
160 | 64 | # WHEN: Call the method. | 65 | # WHEN: Call the method. |
161 | 65 | with patch('PyQt5.QtWidgets.QPushButton.setChecked') as mocked_check_method: | 66 | with patch('PyQt5.QtWidgets.QPushButton.setChecked') as mocked_check_method: |
162 | 66 | self.form._adjust_button(button, checked, enabled, text) | 67 | self.form._adjust_button(button, checked, enabled, text) |
163 | 67 | 68 | ||
164 | 68 | # THEN: The button should be changed. | 69 | # THEN: The button should be changed. |
166 | 69 | self.assertEqual(button.text(), text, "The text should match.") | 70 | self.assertEqual(button.text(), text, 'The text should match.') |
167 | 70 | mocked_check_method.assert_called_once_with(True) | 71 | mocked_check_method.assert_called_once_with(True) |
169 | 71 | self.assertEqual(button.isEnabled(), enabled, "The button should be disabled.") | 72 | self.assertEqual(button.isEnabled(), enabled, 'The button should be disabled.') |
170 | 73 | |||
171 | 74 | def space_key_press_event_test(self): | ||
172 | 75 | """ | ||
173 | 76 | Test the keyPressEvent when the spacebar was pressed | ||
174 | 77 | """ | ||
175 | 78 | # GIVEN: A key event that is a space | ||
176 | 79 | mocked_event = MagicMock() | ||
177 | 80 | mocked_event.key.return_value = QtCore.Qt.Key_Space | ||
178 | 81 | |||
179 | 82 | # WHEN: The event is handled | ||
180 | 83 | with patch.object(self.form, 'keyReleaseEvent') as mocked_key_release_event: | ||
181 | 84 | self.form.keyPressEvent(mocked_event) | ||
182 | 85 | |||
183 | 86 | # THEN: The key should be released | ||
184 | 87 | mocked_key_release_event.assert_called_with(mocked_event) | ||
185 | 88 | self.assertEqual(0, mocked_event.accept.call_count) | ||
186 | 89 | |||
187 | 90 | def primary_push_button_checked_key_press_event_test(self): | ||
188 | 91 | """ | ||
189 | 92 | Test the keyPressEvent when the primary push button is checked | ||
190 | 93 | """ | ||
191 | 94 | # GIVEN: The primary push button is checked | ||
192 | 95 | with patch.object(self.form, 'keyReleaseEvent') as mocked_key_release_event, \ | ||
193 | 96 | patch.object(self.form.primary_push_button, 'isChecked') as mocked_is_checked: | ||
194 | 97 | mocked_is_checked.return_value = True | ||
195 | 98 | mocked_event = MagicMock() | ||
196 | 99 | |||
197 | 100 | # WHEN: The event is handled | ||
198 | 101 | self.form.keyPressEvent(mocked_event) | ||
199 | 102 | |||
200 | 103 | # THEN: The key should be released | ||
201 | 104 | mocked_key_release_event.assert_called_with(mocked_event) | ||
202 | 105 | self.assertEqual(0, mocked_event.accept.call_count) | ||
203 | 106 | |||
204 | 107 | def alternate_push_button_checked_key_press_event_test(self): | ||
205 | 108 | """ | ||
206 | 109 | Test the keyPressEvent when the alternate push button is checked | ||
207 | 110 | """ | ||
208 | 111 | # GIVEN: The primary push button is checked | ||
209 | 112 | with patch.object(self.form, 'keyReleaseEvent') as mocked_key_release_event, \ | ||
210 | 113 | patch.object(self.form.alternate_push_button, 'isChecked') as mocked_is_checked: | ||
211 | 114 | mocked_is_checked.return_value = True | ||
212 | 115 | mocked_event = MagicMock() | ||
213 | 116 | |||
214 | 117 | # WHEN: The event is handled | ||
215 | 118 | self.form.keyPressEvent(mocked_event) | ||
216 | 119 | |||
217 | 120 | # THEN: The key should be released | ||
218 | 121 | mocked_key_release_event.assert_called_with(mocked_event) | ||
219 | 122 | self.assertEqual(0, mocked_event.accept.call_count) | ||
220 | 123 | |||
221 | 124 | def escape_key_press_event_test(self): | ||
222 | 125 | """ | ||
223 | 126 | Test the keyPressEvent when the escape key was pressed | ||
224 | 127 | """ | ||
225 | 128 | # GIVEN: A key event that is an escape | ||
226 | 129 | mocked_event = MagicMock() | ||
227 | 130 | mocked_event.key.return_value = QtCore.Qt.Key_Escape | ||
228 | 131 | |||
229 | 132 | # WHEN: The event is handled | ||
230 | 133 | with patch.object(self.form, 'close') as mocked_close: | ||
231 | 134 | self.form.keyPressEvent(mocked_event) | ||
232 | 135 | |||
233 | 136 | # THEN: The key should be released | ||
234 | 137 | mocked_event.accept.assert_called_with() | ||
235 | 138 | mocked_close.assert_called_with() | ||
236 | 139 | |||
237 | 140 | def on_default_radio_button_not_toggled_test(self): | ||
238 | 141 | """ | ||
239 | 142 | Test that the default radio button method exits early when the button is not toggled | ||
240 | 143 | """ | ||
241 | 144 | # GIVEN: A not-toggled custom radio button | ||
242 | 145 | with patch.object(self.form, '_current_item_action') as mocked_current_item_action: | ||
243 | 146 | |||
244 | 147 | # WHEN: The clicked method is called | ||
245 | 148 | self.form.on_default_radio_button_clicked(False) | ||
246 | 149 | |||
247 | 150 | # THEN: The method should exit early (i.e. the rest of the methods are not called) | ||
248 | 151 | self.assertEqual(0, mocked_current_item_action.call_count) | ||
249 | 152 | |||
250 | 153 | def on_default_radio_button_clicked_no_action_test(self): | ||
251 | 154 | """ | ||
252 | 155 | Test that nothing happens when an action hasn't been selected and you click the default radio button | ||
253 | 156 | """ | ||
254 | 157 | # GIVEN: Some mocked out methods, a current action, and some shortcuts | ||
255 | 158 | with patch.object(self.form, '_current_item_action') as mocked_current_item_action, \ | ||
256 | 159 | patch.object(self.form, '_action_shortcuts') as mocked_action_shortcuts: | ||
257 | 160 | mocked_current_item_action.return_value = None | ||
258 | 161 | |||
259 | 162 | # WHEN: The default radio button is clicked | ||
260 | 163 | self.form.on_default_radio_button_clicked(True) | ||
261 | 164 | |||
262 | 165 | # THEN: The method should exit early (i.e. the rest of the methods are not called) | ||
263 | 166 | mocked_current_item_action.assert_called_with() | ||
264 | 167 | self.assertEqual(0, mocked_action_shortcuts.call_count) | ||
265 | 168 | |||
266 | 169 | def on_default_radio_button_clicked_test(self): | ||
267 | 170 | """ | ||
268 | 171 | Test that the values are copied across correctly when the default radio button is selected | ||
269 | 172 | """ | ||
270 | 173 | # GIVEN: Some mocked out methods, a current action, and some shortcuts | ||
271 | 174 | with patch.object(self.form, '_current_item_action') as mocked_current_item_action, \ | ||
272 | 175 | patch.object(self.form, '_action_shortcuts') as mocked_action_shortcuts, \ | ||
273 | 176 | patch.object(self.form, 'refresh_shortcut_list') as mocked_refresh_shortcut_list, \ | ||
274 | 177 | patch.object(self.form, 'get_shortcut_string') as mocked_get_shortcut_string, \ | ||
275 | 178 | patch.object(self.form.primary_push_button, 'setText') as mocked_set_text: | ||
276 | 179 | mocked_action = MagicMock() | ||
277 | 180 | mocked_action.default_shortcuts = [QtCore.Qt.Key_Escape] | ||
278 | 181 | mocked_current_item_action.return_value = mocked_action | ||
279 | 182 | mocked_action_shortcuts.return_value = [QtCore.Qt.Key_Escape] | ||
280 | 183 | mocked_get_shortcut_string.return_value = 'Esc' | ||
281 | 184 | |||
282 | 185 | # WHEN: The default radio button is clicked | ||
283 | 186 | self.form.on_default_radio_button_clicked(True) | ||
284 | 187 | |||
285 | 188 | # THEN: The shorcuts should be copied across | ||
286 | 189 | mocked_current_item_action.assert_called_with() | ||
287 | 190 | mocked_action_shortcuts.assert_called_with(mocked_action) | ||
288 | 191 | mocked_refresh_shortcut_list.assert_called_with() | ||
289 | 192 | mocked_set_text.assert_called_with('Esc') | ||
290 | 193 | |||
291 | 194 | def on_custom_radio_button_not_toggled_test(self): | ||
292 | 195 | """ | ||
293 | 196 | Test that the custom radio button method exits early when the button is not toggled | ||
294 | 197 | """ | ||
295 | 198 | # GIVEN: A not-toggled custom radio button | ||
296 | 199 | with patch.object(self.form, '_current_item_action') as mocked_current_item_action: | ||
297 | 200 | |||
298 | 201 | # WHEN: The clicked method is called | ||
299 | 202 | self.form.on_custom_radio_button_clicked(False) | ||
300 | 203 | |||
301 | 204 | # THEN: The method should exit early (i.e. the rest of the methods are not called) | ||
302 | 205 | self.assertEqual(0, mocked_current_item_action.call_count) | ||
303 | 206 | |||
304 | 207 | def on_custom_radio_button_clicked_test(self): | ||
305 | 208 | """ | ||
306 | 209 | Test that the values are copied across correctly when the custom radio button is selected | ||
307 | 210 | """ | ||
308 | 211 | # GIVEN: Some mocked out methods, a current action, and some shortcuts | ||
309 | 212 | with patch.object(self.form, '_current_item_action') as mocked_current_item_action, \ | ||
310 | 213 | patch.object(self.form, '_action_shortcuts') as mocked_action_shortcuts, \ | ||
311 | 214 | patch.object(self.form, 'refresh_shortcut_list') as mocked_refresh_shortcut_list, \ | ||
312 | 215 | patch.object(self.form, 'get_shortcut_string') as mocked_get_shortcut_string, \ | ||
313 | 216 | patch.object(self.form.primary_push_button, 'setText') as mocked_set_text: | ||
314 | 217 | mocked_action = MagicMock() | ||
315 | 218 | mocked_current_item_action.return_value = mocked_action | ||
316 | 219 | mocked_action_shortcuts.return_value = [QtCore.Qt.Key_Escape] | ||
317 | 220 | mocked_get_shortcut_string.return_value = 'Esc' | ||
318 | 221 | |||
319 | 222 | # WHEN: The custom radio button is clicked | ||
320 | 223 | self.form.on_custom_radio_button_clicked(True) | ||
321 | 224 | |||
322 | 225 | # THEN: The shorcuts should be copied across | ||
323 | 226 | mocked_current_item_action.assert_called_with() | ||
324 | 227 | mocked_action_shortcuts.assert_called_with(mocked_action) | ||
325 | 228 | mocked_refresh_shortcut_list.assert_called_with() | ||
326 | 229 | mocked_set_text.assert_called_with('Esc') | ||
327 | 230 |
Starting on line 197, there is a repeated comment which says:
# WHEN: The even is handled
But should say
# WHEN: The event is handled
Running this search and replace on the code should fix it if you use vim:
%s/ even / event /g
Alternatively, I'm sure you know how to use the search and replace in your favourite editor.