コード例 #1
0
ファイル: test_servicemanager.py プロジェクト: ipic/projecao
    def test_save_file_raises_permission_error(self, mocked_os,
                                               mocked_save_file_as,
                                               mocked_zipfile):
        """
        Test that when a PermissionError is raised when trying to save a file, it is handled correctly
        """
        # GIVEN: A service manager, a service to save
        mocked_main_window = MagicMock()
        mocked_main_window.service_manager_settings_section = 'servicemanager'
        Registry().register('main_window', mocked_main_window)
        Registry().register('application', MagicMock())
        service_manager = ServiceManager(None)
        service_manager._service_path = MagicMock()
        service_manager._save_lite = False
        service_manager.service_items = []
        service_manager.service_theme = 'Default'
        service_manager.service_manager_list = MagicMock()
        mocked_save_file_as.return_value = True
        mocked_zipfile.ZipFile.return_value = MagicMock()
        mocked_os.link.side_effect = PermissionError

        # WHEN: The service is saved and a PermissionError is raised
        result = service_manager.save_file()

        # THEN: The "save_as" method is called to save the service
        assert result is True
        mocked_save_file_as.assert_called_with()
コード例 #2
0
ファイル: test_servicemanager.py プロジェクト: ipic/projecao
 def test_create_basic_service(self):
     """
     Test the create basic service array
     """
     # GIVEN: A new service manager instance.
     service_manager = ServiceManager(None)
     # WHEN: when the basic service array is created.
     service_manager._save_lite = False
     service_manager.service_theme = 'test_theme'
     service = service_manager.create_basic_service()[0]
     # THEN: The controller should be registered in the registry.
     assert service is not None, 'The base service should be created'
     assert service['openlp_core'][
         'service-theme'] == 'test_theme', 'The test theme should be saved'
     assert service['openlp_core'][
         'lite-service'] is False, 'The lite service should be saved'