Example #1
0
    def test_read_kickstart_warning(self):
        """Test ReadKickstart with a custom warning."""
        class Service(KickstartService):
            def process_kickstart(self, data):
                warnings.warn("First warning!", KickstartParseWarning)
                warnings.warn("Other warning!", DeprecationWarning)
                warnings.warn("Second warning!", KickstartDeprecationWarning)

        module = Service()
        interface = KickstartModuleInterface(module)

        first_warning = {
            'file-name': get_variant(Str, ""),
            'line-number': get_variant(UInt32, 0),
            'message': get_variant(Str, 'First warning!'),
            'module-name': get_variant(Str, ""),
        }

        second_warning = {
            'file-name': get_variant(Str, ""),
            'line-number': get_variant(UInt32, 0),
            'message': get_variant(Str, 'Second warning!'),
            'module-name': get_variant(Str, ""),
        }

        report = {
            'error-messages':
            get_variant(List[Structure], []),
            'warning-messages':
            get_variant(List[Structure], [first_warning, second_warning])
        }

        self.assertEqual(interface.ReadKickstart(""), report)
Example #2
0
    def test_default_configure_bootloader_with_tasks(self):
        """Test the ConfigureBootloaderWithTasks method with defaults."""
        service = KickstartService()
        interface = KickstartModuleInterface(service)

        tasks = interface.ConfigureBootloaderWithTasks(["1", "2", "3"])
        self.assertEqual(tasks, [])
Example #3
0
    def test_configure_bootloader_with_tasks(self, publisher):
        """Test the ConfigureBootloaderWithTasks method."""
        class Task1(Task):
            @property
            def name(self):
                """The name of the task."""
                return "Task 1"

            def run(self):
                """Nothing to do."""

        class Service(KickstartService):
            def configure_bootloader_with_tasks(self, kernel_versions):
                """Return a list of installation tasks."""
                return [Task1()]

        service = Service()
        interface = KickstartModuleInterface(service)

        tasks = interface.ConfigureBootloaderWithTasks(["1", "2", "3"])
        check_task_creation_list(self, tasks, publisher, [Task1])
Example #4
0
    def test_read_kickstart_error_line_number(self):
        """Test ReadKickstart with a custom error on a specified line."""
        class Service(KickstartService):
            def process_kickstart(self, data):
                raise KickstartParseError("Error!", lineno=10)

        module = Service()
        interface = KickstartModuleInterface(module)

        error = {
            'file-name': get_variant(Str, ""),
            'line-number': get_variant(UInt32, 10),
            'message': get_variant(Str, 'Error!'),
            'module-name': get_variant(Str, ""),
        }

        report = {
            'error-messages': get_variant(List[Structure], [error]),
            'warning-messages': get_variant(List[Structure], [])
        }

        self.assertEqual(interface.ReadKickstart(""), report)