Beispiel #1
0
    def on_slide_selected_index_service_item_not_command_test(self, mocked_execute):
        """
        Test that when there is a service item but it's not a command, the preview widget is updated
        """
        # GIVEN: A mocked service item and a slide controller with a service item
        mocked_item = MagicMock()
        mocked_item.is_command.return_value = False
        mocked_item.name = 'Mocked Item'
        mocked_update_preview = MagicMock()
        mocked_preview_widget = MagicMock()
        mocked_slide_selected = MagicMock()
        Registry.create()
        slide_controller = SlideController(None)
        slide_controller.service_item = mocked_item
        slide_controller.update_preview = mocked_update_preview
        slide_controller.preview_widget = mocked_preview_widget
        slide_controller.slide_selected = mocked_slide_selected

        # WHEN: The method is called
        slide_controller.on_slide_selected_index([7])

        # THEN: It should have sent a notification
        mocked_item.is_command.assert_called_once_with()
        self.assertEqual(0, mocked_execute.call_count, 'Execute should not have been called')
        self.assertEqual(0, mocked_update_preview.call_count, 'Update preview should not have been called')
        mocked_preview_widget.change_slide.assert_called_once_with(7)
        mocked_slide_selected.assert_called_once_with()
Beispiel #2
0
    def on_slide_selected_index_service_item_command_test(self, mocked_execute):
        """
        Test that when there is a command service item, the command is executed
        """
        # GIVEN: A mocked service item and a slide controller with a service item
        mocked_item = MagicMock()
        mocked_item.is_command.return_value = True
        mocked_item.name = 'Mocked Item'
        mocked_update_preview = MagicMock()
        mocked_preview_widget = MagicMock()
        mocked_slide_selected = MagicMock()
        Registry.create()
        slide_controller = SlideController(None)
        slide_controller.service_item = mocked_item
        slide_controller.update_preview = mocked_update_preview
        slide_controller.preview_widget = mocked_preview_widget
        slide_controller.slide_selected = mocked_slide_selected
        slide_controller.is_live = True

        # WHEN: The method is called
        slide_controller.on_slide_selected_index([9])

        # THEN: It should have sent a notification
        mocked_item.is_command.assert_called_once_with()
        mocked_execute.assert_called_once_with('mocked item_slide', [mocked_item, True, 9])
        mocked_update_preview.assert_called_once_with()
        self.assertEqual(0, mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called')
        self.assertEqual(0, mocked_slide_selected.call_count, 'slide_selected should not have been called')
Beispiel #3
0
    def on_go_live_service_manager_test(self):
        """
        Test that when the on_go_live() method is called the message is sent to the live controller and focus is
        set correctly.
        """
        # GIVEN: A new SlideController instance and service manager preview then pressing go live should respond
        mocked_display = MagicMock()
        mocked_service_manager = MagicMock()
        mocked_live_controller = MagicMock()
        mocked_preview_widget = MagicMock()
        mocked_service_item = MagicMock()
        mocked_service_item.from_service = True
        mocked_service_item.unique_identifier = 42
        mocked_preview_widget.current_slide_number.return_value = 1
        mocked_preview_widget.slide_count.return_value = 2
        mocked_live_controller.preview_widget = MagicMock()
        Registry.create()
        Registry().register('live_controller', mocked_live_controller)
        Registry().register('service_manager', mocked_service_manager)
        slide_controller = SlideController(None)
        slide_controller.service_item = mocked_service_item
        slide_controller.preview_widget = mocked_preview_widget
        slide_controller.display = mocked_display

        # WHEN: on_go_live() is called
        slide_controller.on_go_live()

        # THEN: the service manager should have the service item and the focus set to live
        mocked_service_manager.preview_live.assert_called_once_with(42, 1)
        mocked_live_controller.preview_widget.setFocus.assert_called_once_with()
Beispiel #4
0
 def setUp(self):
     """
     Some set up for this test suite
     """
     self.setup_application()
     self.app.setApplicationVersion('0.0')
     self.app.process_events = lambda: None
     Registry.create()
     Registry().register('application', self.app)
Beispiel #5
0
 def setUp(self):
     """
     Some set up for this test suite
     """
     self.setup_application()
     self.app.setApplicationVersion('0.0')
     self.app.process_events = lambda: None
     Registry.create()
     Registry().register('application', self.app)
 def setUp(self):
     """
     Initial setups
     """
     Registry.create()
     test_song_name = 'TestSong'
     self.file_name = os.path.join('tests', 'resources', 'songselect', test_song_name)
     self.title = 'Test Song'
     self.ccli_number = '0000000'
     self.authors = ['Author One', 'Author Two']
     self.topics = ['Adoration', 'Praise']
Beispiel #7
0
    def initial_preview_controller_test(self):
        """
        Test the initial preview slide controller state.
        """
        # GIVEN: A new SlideController instance.
        Registry.create()
        preview_controller = PreviewController(None)

        # WHEN: the default controller is built.
        # THEN: The controller should not be a live controller.
        self.assertEqual(preview_controller.is_live, False, 'The slide controller should be a Preview controller')
Beispiel #8
0
    def initial_live_controller_test(self):
        """
        Test the initial live slide controller state .
        """
        # GIVEN: A new SlideController instance.
        Registry.create()
        live_controller = LiveController(None)

        # WHEN: the default controller is built.
        # THEN: The controller should not be a live controller.
        self.assertEqual(live_controller.is_live, True, 'The slide controller should be a live controller')
Beispiel #9
0
 def setUp(self):
     """
     Initial setups
     """
     Registry.create()
     test_song_name = 'TestSong'
     self.file_name = os.path.join('tests', 'resources', 'songselect',
                                   test_song_name)
     self.title = 'Test Song'
     self.ccli_number = '0000000'
     self.authors = ['Author One', 'Author Two']
     self.topics = ['Adoration', 'Praise']
Beispiel #10
0
    def update_slide_limits_test(self, MockedSettings):
        """
        Test that calling the update_slide_limits() method updates the slide limits
        """
        # GIVEN: A mocked out Settings object, a new SlideController and a mocked out main_window
        mocked_value = MagicMock(return_value=10)
        MockedSettings.return_value = MagicMock(value=mocked_value)
        mocked_main_window = MagicMock(advanced_settings_section='advanced')
        Registry.create()
        Registry().register('main_window', mocked_main_window)
        slide_controller = SlideController(None)

        # WHEN: update_slide_limits() is called
        slide_controller.update_slide_limits()

        # THEN: The value of slide_limits should be 10
        mocked_value.assert_called_once_with('advanced/slide limits')
        self.assertEqual(10, slide_controller.slide_limits, 'Slide limits should have been updated to 10')
Beispiel #11
0
    def live_escape_test(self):
        """
        Test that when the live_escape() method is called, the display is set to invisible and any media is stopped
        """
        # GIVEN: A new SlideController instance and mocked out display and media_controller
        mocked_display = MagicMock()
        mocked_media_controller = MagicMock()
        Registry.create()
        Registry().register('media_controller', mocked_media_controller)
        slide_controller = SlideController(None)
        slide_controller.display = mocked_display
        play_slides = MagicMock()
        play_slides.isChecked.return_value = False
        slide_controller.play_slides_loop = play_slides
        slide_controller.play_slides_once = play_slides

        # WHEN: live_escape() is called
        slide_controller.live_escape()

        # THEN: the display should be set to invisible and the media controller stopped
        mocked_display.setVisible.assert_called_once_with(False)
        mocked_media_controller.media_stop.assert_called_once_with(slide_controller)
Beispiel #12
0
 def setUp(self):
     Registry.create()
 def setUp(self):
     Registry.create()