~suutari-olli/openlp/escape-fixes-1294111-1497637

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core_lib/test_lib.py

  • Committer: suutari-olli
  • Date: 2016-01-07 02:53:59 UTC
  • mfrom: (2557.2.31 openlp)
  • Revision ID: suutari.olli@gmail.com-20160107025359-q2feybbwxaoihqxr
Merge to trunk on 1/7/2015.

I noticed this branch also seems to be fixing this bug:
https://bugs.launchpad.net/openlp/+bug/1531691

However, escape item still remains buggy with problems related to resuming
video and presentations.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection                                      #
6
6
# --------------------------------------------------------------------------- #
7
 
# Copyright (c) 2008-2015 OpenLP Developers                                   #
 
7
# Copyright (c) 2008-2016 OpenLP Developers                                   #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it     #
10
10
# under the terms of the GNU General Public License as published by the Free  #
27
27
from unittest import TestCase
28
28
from datetime import datetime, timedelta
29
29
 
30
 
from PyQt4 import QtCore, QtGui
 
30
from PyQt5 import QtCore, QtGui
31
31
 
32
32
from openlp.core.lib import build_icon, check_item_selected, clean_tags, create_thumb, create_separated_list, \
33
33
    expand_tags, get_text_file_string, image_to_byte, resize_image, str_to_bool, validate_thumb
230
230
            # GIVEN: A set of mocked-out Qt classes
231
231
            mocked_byte_array = MagicMock()
232
232
            MockedQtCore.QByteArray.return_value = mocked_byte_array
233
 
            mocked_byte_array.toBase64.return_value = QtCore.QByteArray('base64mock')
 
233
            mocked_byte_array.toBase64.return_value = QtCore.QByteArray(b'base64mock')
234
234
            mocked_buffer = MagicMock()
235
235
            MockedQtCore.QBuffer.return_value = mocked_buffer
236
236
            MockedQtCore.QIODevice.WriteOnly = 'writeonly'
286
286
        """
287
287
        Test that the check_item_selected() function returns True when there are selected indexes
288
288
        """
289
 
        # GIVEN: A mocked out QtGui module and a list widget with selected indexes
290
 
        mocked_QtGui = patch('openlp.core.lib.QtGui')
 
289
        # GIVEN: A mocked out QtWidgets module and a list widget with selected indexes
 
290
        mocked_QtWidgets = patch('openlp.core.lib.QtWidgets')
291
291
        mocked_list_widget = MagicMock()
292
292
        mocked_list_widget.selectedIndexes.return_value = True
293
293
        message = 'message'
303
303
        """
304
304
        Test that the check_item_selected() function returns False when there are no selected indexes.
305
305
        """
306
 
        # GIVEN: A mocked out QtGui module and a list widget with selected indexes
307
 
        with patch('openlp.core.lib.QtGui') as MockedQtGui, \
 
306
        # GIVEN: A mocked out QtWidgets module and a list widget with selected indexes
 
307
        with patch('openlp.core.lib.QtWidgets') as MockedQtWidgets, \
308
308
                patch('openlp.core.lib.translate') as mocked_translate:
309
309
            mocked_translate.return_value = 'mocked translate'
310
310
            mocked_list_widget = MagicMock()
317
317
 
318
318
            # THEN: The selectedIndexes function should have been called and the result should be true
319
319
            mocked_list_widget.selectedIndexes.assert_called_with()
320
 
            MockedQtGui.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message')
 
320
            MockedQtWidgets.QMessageBox.information.assert_called_with('parent', 'mocked translate', 'message')
321
321
            self.assertFalse(result, 'The result should be False')
322
322
 
323
323
    def clean_tags_test(self):