Exemple #1
0
    def test_load_valid_media(self):
        """
        Test the load() method of SystemPlayer with a valid media file
        """
        # GIVEN: A SystemPlayer instance and a mocked display
        player = SystemPlayer(self)
        mocked_display = MagicMock()
        mocked_display.controller.media_info.volume = 1
        mocked_display.controller.media_info.file_info.absoluteFilePath.return_value = '/path/to/file'

        # WHEN: The load() method is run
        with patch.object(player, 'check_media') as mocked_check_media, \
                patch.object(player, 'volume') as mocked_volume:
            mocked_check_media.return_value = True
            result = player.load(mocked_display)

        # THEN: the file is sent to the video widget
        mocked_display.controller.media_info.file_info.absoluteFilePath.assert_called_once_with(
        )
        mocked_check_media.assert_called_once_with('/path/to/file')
        mocked_display.media_player.setMedia.assert_called_once_with(
            QtMultimedia.QMediaContent(
                QtCore.QUrl.fromLocalFile('/path/to/file')))
        mocked_volume.assert_called_once_with(mocked_display, 1)
        assert result is True
Exemple #2
0
    def test_load_invalid_media(self):
        """
        Test the load() method of SystemPlayer with an invalid media file
        """
        # GIVEN: A SystemPlayer instance and a mocked display
        player = SystemPlayer(self)
        mocked_display = MagicMock()
        mocked_display.controller.media_info.volume = 1
        mocked_display.controller.media_info.file_info.absoluteFilePath.return_value = '/path/to/file'

        # WHEN: The load() method is run
        with patch.object(player, 'check_media') as mocked_check_media, \
                patch.object(player, 'volume') as mocked_volume:
            mocked_check_media.return_value = False
            result = player.load(mocked_display)

        # THEN: stuff
        mocked_display.controller.media_info.file_info.absoluteFilePath.assert_called_once_with()
        mocked_check_media.assert_called_once_with('/path/to/file')
        self.assertFalse(result)
Exemple #3
0
    def test_load_invalid_media(self):
        """
        Test the load() method of SystemPlayer with an invalid media file
        """
        # GIVEN: A SystemPlayer instance and a mocked display
        player = SystemPlayer(self)
        mocked_display = MagicMock()
        mocked_display.controller.media_info.volume = 1
        mocked_display.controller.media_info.file_info.absoluteFilePath.return_value = '/path/to/file'

        # WHEN: The load() method is run
        with patch.object(player, 'check_media') as mocked_check_media, \
                patch.object(player, 'volume'):
            mocked_check_media.return_value = False
            result = player.load(mocked_display)

        # THEN: stuff
        mocked_display.controller.media_info.file_info.absoluteFilePath.assert_called_once_with(
        )
        mocked_check_media.assert_called_once_with('/path/to/file')
        assert result is False
Exemple #4
0
    def test_load_valid_media(self):
        """
        Test the load() method of SystemPlayer with a valid media file
        """
        # GIVEN: A SystemPlayer instance and a mocked display
        player = SystemPlayer(self)
        mocked_display = MagicMock()
        mocked_display.controller.media_info.volume = 1
        mocked_display.controller.media_info.file_info.absoluteFilePath.return_value = '/path/to/file'

        # WHEN: The load() method is run
        with patch.object(player, 'check_media') as mocked_check_media, \
                patch.object(player, 'volume') as mocked_volume:
            mocked_check_media.return_value = True
            result = player.load(mocked_display)

        # THEN: the file is sent to the video widget
        mocked_display.controller.media_info.file_info.absoluteFilePath.assert_called_once_with()
        mocked_check_media.assert_called_once_with('/path/to/file')
        mocked_display.media_player.setMedia.assert_called_once_with(
            QtMultimedia.QMediaContent(QtCore.QUrl.fromLocalFile('/path/to/file')))
        mocked_volume.assert_called_once_with(mocked_display, 1)
        self.assertTrue(result)