Example #1
0
    def test_over_write_message_box_no(self):
        """
        Test that theme_manager.over_write_message_box returns False when the user clicks no.
        """
        # GIVEN: A patched QMessageBox.question and an instance of ThemeManager
        with patch('openlp.core.ui.thememanager.QtWidgets.QMessageBox.question', return_value=QtWidgets.QMessageBox.No)\
                as mocked_qmessagebox_question,\
                patch('openlp.core.ui.thememanager.translate') as mocked_translate:
            mocked_translate.side_effect = lambda context, text: text
            theme_manager = ThemeManager(None)

            # WHEN: Calling over_write_message_box with 'Theme Name'
            result = theme_manager.over_write_message_box('Theme Name')

            # THEN: over_write_message_box should return False and the message box should contain the theme name
            self.assertFalse(result)
            mocked_qmessagebox_question.assert_called_once_with(
                theme_manager, 'Theme Already Exists', 'Theme Theme Name already exists. Do you want to replace it?',
                ANY, ANY)
Example #2
0
    def test_over_write_message_box_no(self, mocked_translate,
                                       mocked_qmessagebox_question):
        """
        Test that theme_manager.over_write_message_box returns False when the user clicks no.
        """
        # GIVEN: A patched QMessageBox.question and an instance of ThemeManager
        mocked_translate.side_effect = lambda context, text: text
        theme_manager = ThemeManager(None)

        # WHEN: Calling over_write_message_box with 'Theme Name'
        result = theme_manager.over_write_message_box('Theme Name')

        # THEN: over_write_message_box should return False and the message box should contain the theme name
        assert result is False
        mocked_qmessagebox_question.assert_called_once_with(
            theme_manager,
            'Theme Already Exists',
            'Theme Theme Name already exists. Do you want to replace it?',
            defaultButton=ANY)
Example #3
0
    def over_write_message_box_no_test(self):
        """
        Test that theme_manager.over_write_message_box returns False when the user clicks no.
        """
        # GIVEN: A patched QMessageBox.question and an instance of ThemeManager
        with patch('openlp.core.ui.thememanager.QtGui.QMessageBox.question', return_value=QtGui.QMessageBox.No)\
                as mocked_qmessagebox_question,\
                patch('openlp.core.ui.thememanager.translate') as mocked_translate:
            mocked_translate.side_effect = lambda context, text: text
            theme_manager = ThemeManager(None)

            # WHEN: Calling over_write_message_box with 'Theme Name'
            result = theme_manager.over_write_message_box('Theme Name')

            # THEN: over_write_message_box should return False and the message box should contain the theme name
            self.assertFalse(result)
            mocked_qmessagebox_question.assert_called_once_with(
                theme_manager, 'Theme Already Exists',
                'Theme Theme Name already exists. Do you want to replace it?',
                ANY, ANY)