-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test for task category and category API
- Loading branch information
1 parent
7591330
commit a13a042
Showing
2 changed files
with
94 additions
and
4 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
tests/unit_tests/pyanaconda_tests/modules/boss/test_install_category.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# | ||
# Adam Kaňkovský <[email protected]> | ||
# | ||
# Copyright 2024 Red Hat, Inc. | ||
# | ||
# This copyrighted material is made available to anyone wishing to use, modify, | ||
# copy, or redistribute it subject to the terms and conditions of the GNU | ||
# General Public License v.2. This program is distributed in the hope that it | ||
# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the | ||
# implied warranties 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, write to the Free Software Foundation, Inc., 51 | ||
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat | ||
# trademarks that are incorporated in the source code or documentation are not | ||
# subject to the GNU General Public License and may only be used or replicated | ||
# with the express permission of Red Hat, Inc. | ||
# | ||
import unittest | ||
from unittest.mock import patch, Mock, MagicMock | ||
|
||
from pyanaconda.core.constants import CATEGORY_SYSTEM, CATEGORY_STORAGE | ||
from pyanaconda.installation import RunInstallationTask | ||
from pyanaconda.installation_tasks import TaskQueue, Task | ||
|
||
|
||
# class TestCategoryReportTaskInterface(CategoryReportTaskInterface): | ||
# def __init__(self): | ||
# super().connect_signals() | ||
# self.implementation.category_changed_signal.connect(self.TestCategoryChanged) | ||
# self._categoryList = [] | ||
# | ||
# def categoryList(self): | ||
# return self._categoryList | ||
# | ||
# def TestCategoryChanged(self, category): | ||
# self.categoryList.append(category) | ||
|
||
class TestRunInstallation(RunInstallationTask): | ||
|
||
def __init__(self, payload, ksdata): | ||
super().__init__(payload=payload, ksdata=ksdata) | ||
|
||
|
||
def _prepare_configuration(self, payload, ksdata): | ||
configuration_queue = TaskQueue("Configuration queue") | ||
|
||
# connect progress reporting | ||
configuration_queue.queue_started.connect(self._queue_started_cb) | ||
configuration_queue.task_completed.connect(self._task_completed_cb) | ||
|
||
# Creating task queues with categories | ||
queue1 = TaskQueue(name="group1", task_category=CATEGORY_SYSTEM) | ||
task1 = Task("Test task 1", lambda: None) | ||
queue1.append(task1) | ||
|
||
configuration_queue.append(queue1) | ||
|
||
return configuration_queue | ||
|
||
def _prepare_installation(self, payload, ksdata): | ||
installation_queue = TaskQueue("Installation queue") | ||
|
||
# connect progress reporting | ||
installation_queue.queue_started.connect(self._queue_started_cb) | ||
installation_queue.task_completed.connect(self._task_completed_cb) | ||
|
||
# Creating task queues with categories | ||
queue1 = TaskQueue(name="group2", task_category=CATEGORY_STORAGE) | ||
task1 = Task("Test task 1", lambda: None) | ||
queue1.append(task1) | ||
|
||
installation_queue.append(queue1) | ||
|
||
return installation_queue | ||
|
||
class InstallManagerTestCase(unittest.TestCase): | ||
"""Test the install category API""" | ||
|
||
@patch("pyanaconda.modules.boss.install_manager.installation_category_interface.CategoryReportTaskInterface") | ||
def test_task_category_reporting(self, mock_category_interface): | ||
mock_category_interface.CategoryChanged = MagicMock() | ||
|
||
payload = Mock() | ||
install = TestRunInstallation(ksdata=[], payload=payload) | ||
install.run() | ||
|
||
mock_category_interface.CategoryChanged.assert_called_with(CATEGORY_SYSTEM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters