Exemple #1
0
    def test_accept_method(self, mocked_qwizard_accept, *args):
        """
        Test the FirstTimeForm.accept method
        """
        # GIVEN: An instance of FirstTimeForm
        frw = FirstTimeForm(None)
        with patch.object(frw, '_set_plugin_status') as mocked_set_plugin_status, \
                patch.multiple(frw, songs_check_box=DEFAULT, bible_check_box=DEFAULT, presentation_check_box=DEFAULT,
                               image_check_box=DEFAULT, media_check_box=DEFAULT, custom_check_box=DEFAULT,
                               song_usage_check_box=DEFAULT, alert_check_box=DEFAULT) as mocked_check_boxes, \
                patch.object(frw, 'screen_selection_widget') as mocked_screen_selection_widget:

            # WHEN: Calling accept
            frw.accept()

            # THEN: The selected plugins should be enabled, the screen selection saved and the super method called
            mocked_set_plugin_status.assert_has_calls([
                call(mocked_check_boxes['songs_check_box'], 'songs/status'),
                call(mocked_check_boxes['bible_check_box'], 'bibles/status'),
                call(mocked_check_boxes['presentation_check_box'],
                     'presentations/status'),
                call(mocked_check_boxes['image_check_box'], 'images/status'),
                call(mocked_check_boxes['media_check_box'], 'media/status'),
                call(mocked_check_boxes['custom_check_box'], 'custom/status'),
                call(mocked_check_boxes['song_usage_check_box'],
                     'songusage/status'),
                call(mocked_check_boxes['alert_check_box'], 'alerts/status')
            ])
            mocked_screen_selection_widget.save.assert_called_once()
            mocked_qwizard_accept.assert_called_once()
Exemple #2
0
    def test_accept_method_theme_not_selected(self, mocked_settings):
        """
        Test the FirstTimeForm.accept method when there is no default theme selected
        """
        # GIVEN: An instance of FirstTimeForm
        frw = FirstTimeForm(None)
        with patch.object(frw, '_set_plugin_status'), patch.object(frw, 'screen_selection_widget'), \
                patch.object(frw, 'theme_combo_box', **{'currentIndex.return_value': -1}):

            # WHEN: Calling accept and the currentIndex method of the theme_combo_box returns -1
            frw.accept()

            # THEN: OpenLP should not try to save a theme name
            mocked_settings().setValue.assert_not_called()
Exemple #3
0
    def test_accept_method_theme_selected(self, mocked_settings):
        """
        Test the FirstTimeForm.accept method when a default theme is selected
        """
        # GIVEN: An instance of FirstTimeForm
        frw = FirstTimeForm(None)
        with patch.object(frw, '_set_plugin_status'), \
                patch.object(frw, 'screen_selection_widget'), \
                patch.object(
                frw, 'theme_combo_box', **{'currentIndex.return_value': 0, 'currentText.return_value': 'Test Item'}):

            # WHEN: Calling accept and the currentIndex method of the theme_combo_box returns 0
            frw.accept()

            # THEN: The 'currentItem' in the combobox should have been set as the default theme.
            mocked_settings().setValue.assert_called_once_with(
                'themes/global theme', 'Test Item')