def setUp(self):
        """Set up the payload module."""
        self.payload_module = PayloadsService()
        self.payload_interface = PayloadsInterface(self.payload_module)

        self.shared_ks_tests = PayloadKickstartSharedTest(
            self.payload_module, self.payload_interface)
예제 #2
0
    def setUp(self):
        self.module = PayloadsService()
        self.interface = PayloadsInterface(self.module)

        self.shared_ks_tests = PayloadKickstartSharedTest(self,
                                                          self.module,
                                                          self.interface)
예제 #3
0
 def setUp(self):
     self.maxDiff = None
     self.module = PayloadsService()
     self.interface = PayloadsInterface(self.module)
     self.shared_ks_tests = PayloadKickstartSharedTest(
         test=self,
         payload_service=self.module,
         payload_service_intf=self.interface)
예제 #4
0
    def __init__(self, test, payload_service, payload_service_intf):
        """Setup shared payload test object for common payload testing.

        :param test: instance of TestCase
        :param payload_service: main payload service module
        :param payload_service_intf: main payload service interface
        """
        self._test = test
        self.payload_service = PayloadsService()
        self.payload_service_interface = PayloadsInterface(
            self.payload_service)
예제 #5
0
    def setUp(self):
        self.payload_module = PayloadsService()
        self.payload_module_interface = PayloadsInterface(self.payload_module)

        self.shared_tests = PayloadKickstartSharedTest(
            self, self.payload_module, self.payload_module_interface)

        # test variables
        self._expected_env = ""
        self._expected_packages = []
        self._expected_groups = []
        self._expected_excluded_packages = []
        self._expected_excluded_groups = []
    def setUp(self):
        self.payload_module = PayloadsService()
        self.payload_module_interface = PayloadsInterface(self.payload_module)

        self.shared_tests = PayloadSharedTest(self, self.payload_module,
                                              self.payload_module_interface)
예제 #7
0
#
# Payloads DBus service launcher.
#
# Copyright (C) 2020 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, or (at your option) any later version.
# 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.
#
from pyanaconda.modules.common import init
init()

from pyanaconda.modules.payloads.payloads import PayloadsService
service = PayloadsService()
service.run()
예제 #8
0
class PayloadsInterfaceTestCase(TestCase):

    def setUp(self):
        """Set up the payload module."""
        self.payload_module = PayloadsService()
        self.payload_interface = PayloadsInterface(self.payload_module)

        self.shared_ks_tests = PayloadKickstartSharedTest(self,
                                                          self.payload_module,
                                                          self.payload_interface)

    def kickstart_properties_test(self):
        """Test kickstart properties."""
        self.assertEqual(self.payload_interface.KickstartCommands, [
            "cdrom",
            "harddrive",
            "hmc",
            "liveimg",
            "nfs",
            "ostreesetup",
            "url"
        ])
        self.assertEqual(self.payload_interface.KickstartSections, [
            "packages"
        ])
        self.assertEqual(self.payload_interface.KickstartAddons, [])

    def no_kickstart_test(self):
        """Test kickstart is not set to the payloads service."""
        ks_in = None
        ks_out = ""
        self.shared_ks_tests.check_kickstart(ks_in, ks_out, expected_publish_calls=0)

    def kickstart_empty_test(self):
        """Test kickstart is empty for the payloads service."""
        ks_in = ""
        ks_out = ""
        self.shared_ks_tests.check_kickstart(ks_in, ks_out, expected_publish_calls=0)

    def no_payload_set_test(self):
        """Test empty string is returned when no payload is set."""
        self.assertEqual(self.payload_interface.ActivePayload, "")

    def generate_kickstart_without_payload_test(self):
        """Test kickstart parsing without payload set."""
        self.assertEqual(self.payload_interface.GenerateKickstart(), "")

    def process_kickstart_with_no_payload_test(self):
        """Test kickstart processing when no payload set or created based on KS data."""
        self.payload_interface.ReadKickstart("")
        self.assertEqual(self.payload_interface.ActivePayload, "")

    @patch_dbus_publish_object
    def create_dnf_payload_test(self, publisher):
        """Test creation and publishing of the DNF payload module."""
        payload_path = self.payload_interface.CreatePayload(PayloadType.DNF.value)
        self.assertEqual(self.payload_interface.CreatedPayloads, [payload_path])

        self.payload_interface.ActivatePayload(payload_path)
        self.assertEqual(self.payload_interface.ActivePayload, payload_path)

        self.assertIsInstance(PayloadContainer.from_object_path(payload_path), DNFModule)
        publisher.assert_called_once()

    @patch_dbus_publish_object
    def create_live_os_payload_test(self, publisher):
        """Test creation and publishing of the Live OS payload module."""
        payload_path = self.payload_interface.CreatePayload(PayloadType.LIVE_OS.value)
        self.assertEqual(self.payload_interface.CreatedPayloads, [payload_path])

        self.payload_interface.ActivatePayload(payload_path)
        self.assertEqual(self.payload_interface.ActivePayload, payload_path)

        self.assertIsInstance(PayloadContainer.from_object_path(payload_path), LiveOSModule)
        publisher.assert_called_once()

    @patch_dbus_publish_object
    def create_live_image_payload_test(self, publisher):
        """Test creation and publishing of the Live image payload module."""
        payload_path = self.payload_interface.CreatePayload(PayloadType.LIVE_IMAGE.value)
        self.assertEqual(self.payload_interface.CreatedPayloads, [payload_path])

        self.payload_interface.ActivatePayload(payload_path)
        self.assertEqual(self.payload_interface.ActivePayload, payload_path)

        self.assertIsInstance(PayloadContainer.from_object_path(payload_path), LiveImageModule)
        publisher.assert_called_once()

    @patch_dbus_publish_object
    def create_invalid_payload_test(self, publisher):
        """Test creation of the not existing payload."""
        with self.assertRaises(ValueError):
            self.payload_interface.CreatePayload("NotAPayload")

    @patch_dbus_publish_object
    def create_multiple_payloads_test(self, publisher):
        """Test creating two payloads."""
        path_1 = self.payload_interface.CreatePayload(PayloadType.DNF.value)
        self.assertEqual(self.payload_interface.CreatedPayloads, [path_1])
        self.assertEqual(self.payload_interface.ActivePayload, "")

        path_2 = self.payload_interface.CreatePayload(PayloadType.LIVE_OS.value)
        self.assertEqual(self.payload_interface.CreatedPayloads, [path_1, path_2])
        self.assertEqual(self.payload_interface.ActivePayload, "")

        self.payload_interface.ActivatePayload(path_1)
        self.assertEqual(self.payload_interface.ActivePayload, path_1)

        self.payload_interface.ActivatePayload(path_2)
        self.assertEqual(self.payload_interface.ActivePayload, path_2)

        self.assertEqual(publisher.call_count, 2)

    @patch_dbus_publish_object
    def create_live_os_source_test(self, publisher):
        """Test creation of the Live OS source module."""
        source_path = self.payload_interface.CreateSource(SOURCE_TYPE_LIVE_OS_IMAGE)

        check_dbus_object_creation(self, source_path, publisher, LiveOSSourceModule)

    @patch_dbus_publish_object
    def create_invalid_source_test(self, publisher):
        """Test creation of the not existing source."""
        with self.assertRaises(ValueError):
            self.payload_interface.CreateSource("NotASource")

    def is_network_required_test(self):
        """Test the IsNetworkRequired method."""
        self.assertEqual(self.payload_interface.IsNetworkRequired(), False)

        payload = self.payload_module.create_payload(PayloadType.DNF)
        self.payload_module.activate_payload(payload)

        self.assertEqual(self.payload_interface.IsNetworkRequired(), False)

        source = self.payload_module.create_source(SourceType.NFS)
        payload.set_sources([source])

        self.assertEqual(self.payload_interface.IsNetworkRequired(), True)

    def calculate_required_space_test(self):
        """Test the CalculateRequiredTest method."""
        self.assertEqual(self.payload_interface.CalculateRequiredSpace(), 0)

        payload = self.payload_module.create_payload(PayloadType.LIVE_IMAGE)
        self.payload_module.activate_payload(payload)

        self.assertEqual(self.payload_interface.CalculateRequiredSpace(), 0)

        source = self.payload_module.create_source(SourceType.LIVE_IMAGE)
        payload.set_sources([source])

        self.assertEqual(self.payload_interface.CalculateRequiredSpace(), 1024 * 1024 * 1024)

    def get_kernel_version_list_test(self):
        """Test the GetKernelVersionList method."""
        self.assertEqual(self.payload_interface.GetKernelVersionList(), [])

        payload = self.payload_module.create_payload(PayloadType.DNF)
        self.payload_module.activate_payload(payload)

        with self.assertRaises(UnavailableValueError):
            self.payload_interface.GetKernelVersionList()

        payload.set_kernel_version_list(["k1", "k2", "k3"])
        self.assertEqual(self.payload_interface.GetKernelVersionList(), ["k1", "k2", "k3"])

    @patch_dbus_publish_object
    def install_with_tasks_test(self, publisher):
        """Test the InstallWithTasks method."""
        self.assertEqual(self.payload_interface.InstallWithTasks(), [])

        payload = self.payload_module.create_payload(PayloadType.DNF)
        self.payload_module.activate_payload(payload)

        tasks_paths = self.payload_interface.InstallWithTasks()
        check_task_creation_list(self, tasks_paths, publisher, [
            PrepareSystemForInstallationTask
        ])

    @patch_dbus_publish_object
    def post_install_with_tasks_test(self, publisher):
        """Test the PostInstallWithTasks method."""
        self.assertEqual(self.payload_interface.PostInstallWithTasks(), [])

        payload = self.payload_module.create_payload(PayloadType.DNF)
        self.payload_module.activate_payload(payload)

        tasks_paths = self.payload_interface.PostInstallWithTasks()
        check_task_creation_list(self, tasks_paths, publisher, [
            CopyDriverDisksFilesTask
        ])

    @patch_dbus_publish_object
    def tear_down_with_tasks_test(self, publisher):
        """Test the TeardownWithTasks method."""
        self.assertEqual(self.payload_interface.TeardownWithTasks(), [])

        payload = self.payload_module.create_payload(PayloadType.DNF)
        self.payload_module.activate_payload(payload)

        source = self.payload_module.create_source(SourceType.CDROM)
        payload.set_sources([source])

        publisher.reset_mock()
        task_paths = self.payload_interface.TeardownWithTasks()
        check_task_creation_list(self, task_paths, publisher, [TearDownSourcesTask])
 def setUp(self):
     """Set up the payload module."""
     self.payload_module = PayloadsService()
     self.payload_interface = PayloadsInterface(self.payload_module)