# -*- coding: utf-8 -*-

##########################################################################
# OpenLP - Open Source Lyrics Projection                                 #
# ---------------------------------------------------------------------- #
# Copyright (c) 2008-2024 OpenLP Developers                              #
# ---------------------------------------------------------------------- #
# This program is free software: you can redistribute it and/or modify   #
# it under the terms of the GNU General Public License as published by   #
# the Free Software Foundation, either version 3 of the License, or      #
# (at your option) any later version.                                    #
#                                                                        #
# This program is distributed in the hope that it will be useful,        #
# but WITHOUT ANY WARRANTY; without even the implied warranty of         #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          #
# GNU General Public License for more details.                           #
#                                                                        #
# You should have received a copy of the GNU General Public License      #
# along with this program.  If not, see <https://www.gnu.org/licenses/>. #
##########################################################################
"""
Package to test the openlp.core.loader package.
"""
from unittest.mock import MagicMock, patch

from openlp.core.loader import loader


@patch('openlp.core.loader.Renderer', autospec=True)
@patch('openlp.core.loader.PluginManager', autospec=True)
@patch('openlp.core.loader.State', autospec=True)
@patch('openlp.core.loader.MediaController', autospec=True)
@patch('openlp.core.loader.LiveController', autospec=True)
@patch('openlp.core.loader.PreviewController', autospec=True)
def test_loader(MockPreviewController: MagicMock, MockLiveController: MagicMock,
                MockMediaController: MagicMock, MockState: MagicMock, MockPluginManager: MagicMock,
                MockRenderer: MagicMock):
    # GIVEN: A bunch of mocks
    # WHEN: loader() is called
    loader()
    # THEN: The mocks should have been called
    MockState.return_value.load_settings.assert_called_once_with()
    MockMediaController.assert_called_once_with()
    MockPluginManager.assert_called_once_with()
    MockRenderer.assert_called_once_with(window_title='Renderer')
    MockPreviewController.assert_called_once_with()
    MockLiveController.assert_called_once_with()
