Beispiel #1
0
    def test_check_available(self, mocked_log):
        """
        Test `ImpressController.check_available` on Windows
        """
        # GIVEN: An instance of :class:`ImpressController`
        controller = ImpressController(plugin=self.mock_plugin)

        # WHEN: `check_available` is called on Windows and `get_com_servicemanager` returns None
        with patch('openlp.plugins.presentations.lib.impresscontroller.is_win', return_value=True), \
                patch.object(controller, 'get_com_servicemanager', return_value=None) as mocked_get_com_servicemanager:
            result = controller.check_available()

            # THEN: `check_available` should return False
            assert mocked_get_com_servicemanager.called is True
            assert result is False
    def test_start_process_on_windows(self, mocked_is_win):
        """
        Test that start_process() on Windows starts the process
        """
        # GIVEN: An ImpressController object
        controller = ImpressController(plugin=self.mock_plugin)
        controller.get_com_servicemanager = MagicMock(return_value=MagicMock())

        # WHEN: start_process() is called
        controller.start_process()

        # THEN: The correct methods should have been called
        controller.get_com_servicemanager.assert_called_once()
        assert controller.manager._FlagAsMethod.call_args_list == [call('Bridge_GetStruct'),
                                                                   call('Bridge_GetValueObject')]
    def test_check_available_on_linux(self, mocked_is_win, mocked_log):
        """
        Test `ImpressController.check_available` when not on Windows
        """
        # GIVEN: An instance of :class:`ImpressController`
        controller = ImpressController(plugin=self.mock_plugin)

        # WHEN: `check_available` is called on Windows and `uno_available` is True
        with patch('openlp.plugins.presentations.lib.impresscontroller.uno_available', True), \
                patch.object(controller, 'get_com_servicemanager') as mocked_get_com_servicemanager:
            result = controller.check_available()

            # THEN: `check_available` should return True
            assert mocked_get_com_servicemanager.called is False
            assert result is True
Beispiel #4
0
 def setUp(self):
     mocked_plugin = MagicMock()
     mocked_plugin.settings_section = 'presentations'
     Settings().extend_default_settings(__default_settings__)
     self.file_name = RESOURCE_PATH / 'presentations' / 'test.pptx'
     self.ppc = ImpressController(mocked_plugin)
     self.doc = ImpressDocument(self.ppc, self.file_name)
Beispiel #5
0
 def setUp(self):
     mocked_plugin = MagicMock()
     mocked_plugin.settings_section = 'presentations'
     Settings().extend_default_settings(__default_settings__)
     self.file_name = os.path.join(TEST_RESOURCES_PATH, 'presentations', 'test.pptx')
     self.ppc = ImpressController(mocked_plugin)
     self.doc = ImpressDocument(self.ppc, self.file_name)
    def test_start_process_on_linux(self, MockQProcess, mocked_get_uno_command, mocked_is_win):
        """
        Test that start_process() on Linux starts the process
        """
        # GIVEN: An ImpressController object
        mocked_process = MagicMock()
        MockQProcess.return_value = mocked_process
        controller = ImpressController(plugin=self.mock_plugin)

        # WHEN: start_process() is called
        controller.start_process()

        # THEN: The correct methods should have been called
        mocked_get_uno_command.assert_called_once()
        MockQProcess.assert_called_once()
        assert controller.process is mocked_process
        mocked_process.startDetached.assert_called_once_with('libreoffice')
 def setUp(self):
     mocked_plugin = MagicMock()
     mocked_plugin.settings_section = 'presentations'
     self.file_name = RESOURCE_PATH / 'presentations' / 'test.pptx'
     self.settings = Settings()
     Registry.create()
     Registry().register('settings', self.settings)
     self.ppc = ImpressController(mocked_plugin)
     self.doc = ImpressDocument(self.ppc, self.file_name)
Beispiel #8
0
    def test_constructor(self):
        """
        Test the Constructor from the ImpressController
        """
        # GIVEN: No presentation controller
        controller = None

        # WHEN: The presentation controller object is created
        controller = ImpressController(plugin=self.mock_plugin)

        # THEN: The name of the presentation controller should be correct
        assert 'Impress' == controller.name, 'The name of the presentation controller should be correct'