예제 #1
0
    def test_distribute(self):
        manager = KickstartManager()

        module1 = TestModule(commands=["network", "firewall"])
        module2 = TestModule(addons=["pony"])
        module3 = TestModule(sections=["packages"])
        module4 = TestModule(addons=["scorched"])

        m1_observer = self._get_module_observer("1", module1)
        m2_observer = self._get_module_observer("2", module2)
        m3_observer = self._get_module_observer("3", module3)
        m4_observer = self._get_module_observer("4", module4, available=False)

        manager.on_module_observers_changed([
            m1_observer,
            m2_observer,
            m3_observer,
            m4_observer
        ])

        with self._create_ks_files(self._kickstart_include) as filename:
            report = manager.read_kickstart_file(filename)

        assert module1.kickstart == self._m1_kickstart
        assert module2.kickstart == self._m2_kickstart
        assert module3.kickstart == self._m3_kickstart
        assert module4.kickstart == ""

        assert report.is_valid() is False
        assert len(report.get_messages()) == 2

        error = report.get_messages()[0]
        assert error.module_name == "1"
        assert error.file_name == "ks.manager.test.include1.cfg"
        assert error.line_number == 5
        assert error.message == "Mocked parse error: \"PARSE_ERROR\" found"

        error = report.get_messages()[1]
        assert error.module_name == "3"
        assert error.file_name == "ks.manager.test.include.cfg"
        assert error.line_number == 41
        assert error.message == "Mocked parse error: \"PARSE_ERROR\" found"

        assert manager.generate_kickstart() == self._m123_kickstart
예제 #2
0
    def distribute_test(self):
        manager = KickstartManager()

        module1 = TestModule(commands=["network", "firewall"])
        module2 = TestModule(addons=["pony"])
        module3 = TestModule(sections=["packages"])
        module4 = TestModule(addons=["scorched"])

        m1_observer = self._get_module_observer("1", module1)
        m2_observer = self._get_module_observer("2", module2)
        m3_observer = self._get_module_observer("3", module3)
        m4_observer = self._get_module_observer("4", module4, available=False)

        manager.on_module_observers_changed([
            m1_observer,
            m2_observer,
            m3_observer,
            m4_observer
        ])

        with self._create_ks_files(self._kickstart_include) as filename:
            report = manager.read_kickstart_file(filename)

        self.assertEqual(module1.kickstart, self._m1_kickstart)
        self.assertEqual(module2.kickstart, self._m2_kickstart)
        self.assertEqual(module3.kickstart, self._m3_kickstart)
        self.assertEqual(module4.kickstart, "")

        self.assertEqual(report.is_valid(), False)
        self.assertEqual(len(report.get_messages()), 2)

        error = report.get_messages()[0]
        self.assertEqual(error.module_name, "1")
        self.assertEqual(error.file_name, "ks.manager.test.include1.cfg")
        self.assertEqual(error.line_number, 5)
        self.assertEqual(error.message, "Mocked parse error: \"PARSE_ERROR\" found")

        error = report.get_messages()[1]
        self.assertEqual(error.module_name, "3")
        self.assertEqual(error.file_name, "ks.manager.test.include.cfg")
        self.assertEqual(error.line_number, 41)
        self.assertEqual(error.message, "Mocked parse error: \"PARSE_ERROR\" found")

        self.assertEqual(manager.generate_kickstart(), self._m123_kickstart)