Exemple #1
0
class FlatpakSourceTestCase(unittest.TestCase):
    """Test the OSTree source module."""
    def setUp(self):
        self.module = FlatpakSourceModule()

    def test_type(self):
        """Test the type property."""
        self.assertEqual(self.module.type, SourceType.FLATPAK)

    def test_network_required(self):
        """Test the network_required property."""
        self.assertEqual(self.module.network_required, False)

    def test_required_space(self):
        """Test the required_space property."""
        self.assertEqual(self.module.required_space, 0)

        self.module._set_required_space(1024)
        self.assertEqual(self.module.required_space, 1024)

    @patch(
        "pyanaconda.modules.payloads.source.flatpak.flatpak.GetFlatpaksSizeTask.run"
    )
    def test_set_required_space_with_task(self, run_mock):
        """Set the required_space property with a task."""
        run_mock.return_value = 1024

        for task in self.module.set_up_with_tasks():
            task.run_with_signals()

        self.assertEqual(self.module.required_space, 1024)

    def test_get_state(self):
        """Test the source state."""
        self.assertEqual(self.module.get_state(), SourceState.NOT_APPLICABLE)

    def test_set_up_with_tasks(self):
        """Test the set-up tasks."""
        tasks = self.module.set_up_with_tasks()

        self.assertEqual(len(tasks), 1)
        self.assertIsInstance(tasks[0], GetFlatpaksSizeTask)

    def test_tear_down_with_tasks(self):
        """Test the tear-down tasks."""
        self.assertEqual(self.module.tear_down_with_tasks(), [])

    def test_repr(self):
        """Test the string representation."""
        self.assertEqual(repr(self.module), "Source(type='FLATPAK')")
Exemple #2
0
class FlatpakSourceTestCase(unittest.TestCase):
    """Test the OSTree source module."""
    def setUp(self):
        self.module = FlatpakSourceModule()

    def test_type(self):
        """Test the type property."""
        assert self.module.type == SourceType.FLATPAK

    def test_network_required(self):
        """Test the network_required property."""
        assert self.module.network_required == False

    def test_required_space(self):
        """Test the required_space property."""
        assert self.module.required_space == 0

        self.module._set_required_space(1024)
        assert self.module.required_space == 1024

    @patch(
        "pyanaconda.modules.payloads.source.flatpak.flatpak.GetFlatpaksSizeTask.run"
    )
    def test_set_required_space_with_task(self, run_mock):
        """Set the required_space property with a task."""
        run_mock.return_value = 1024

        for task in self.module.set_up_with_tasks():
            task.run_with_signals()

        assert self.module.required_space == 1024

    def test_get_state(self):
        """Test the source state."""
        assert self.module.get_state() == SourceState.NOT_APPLICABLE

    def test_set_up_with_tasks(self):
        """Test the set-up tasks."""
        tasks = self.module.set_up_with_tasks()

        assert len(tasks) == 1
        assert isinstance(tasks[0], GetFlatpaksSizeTask)

    def test_tear_down_with_tasks(self):
        """Test the tear-down tasks."""
        assert self.module.tear_down_with_tasks() == []

    def test_repr(self):
        """Test the string representation."""
        assert repr(self.module) == "Source(type='FLATPAK')"