def test_invalid_image(self):
        """Test an invalid image."""
        configuration = LiveImageConfigurationData()
        configuration.url = "file:///my/invalid/path"

        task = SetUpLocalImageSourceTask(configuration)
        with pytest.raises(SourceSetupError) as cm:
            task.run()

        assert str(cm.value) == "File /my/invalid/path does not exist."
    def invalid_image_test(self):
        """Test an invalid image."""
        configuration = LiveImageConfigurationData()
        configuration.url = "file:///my/invalid/path"

        task = SetUpLocalImageSourceTask(configuration)
        with self.assertRaises(SourceSetupError) as cm:
            task.run()

        self.assertEqual(str(cm.exception),
                         "File /my/invalid/path does not exist.")
    def empty_image_test(self):
        """Test an empty image."""
        with tempfile.NamedTemporaryFile("w") as f:
            # Run the task.
            configuration = LiveImageConfigurationData()
            configuration.url = "file://" + f.name

            task = SetUpLocalImageSourceTask(configuration)
            result = task.run()

            # Check the result.
            self.assertIsInstance(result, SetupImageResult)
            self.assertEqual(result, SetupImageResult(None))
Exemplo n.º 4
0
    def set_up_with_tasks(self):
        """Set up the installation source for installation.

        :return: list of tasks required for the source setup
        :rtype: [Task]
        """
        if self.is_local:
            task = SetUpLocalImageSourceTask(self.configuration)
        else:
            task = SetUpRemoteImageSourceTask(self.configuration)

        handler = self._handle_setup_task_result
        task.succeeded_signal.connect(lambda: handler(task.get_result()))
        return [task]
    def test_empty_image(self, os_stat):
        """Test an empty image."""
        os_stat.return_value = Mock(st_blocks=0)

        with tempfile.NamedTemporaryFile("w") as f:
            # Run the task.
            configuration = LiveImageConfigurationData()
            configuration.url = "file://" + f.name

            task = SetUpLocalImageSourceTask(configuration)
            result = task.run()

            # Check the result.
            assert isinstance(result, SetupImageResult)
            assert result == SetupImageResult(None)
    def fake_image_test(self):
        """Test a fake image."""
        with tempfile.NamedTemporaryFile("w") as f:
            # Create a fake image.
            f.write("MY FAKE IMAGE")
            f.flush()

            # Run the task.
            configuration = LiveImageConfigurationData()
            configuration.url = "file://" + f.name

            task = SetUpLocalImageSourceTask(configuration)
            result = task.run()

            # Check the result.
            self.assertIsInstance(result, SetupImageResult)
            self.assertGreater(result.required_space, 0)
    def fake_image_test(self, os_stat):
        """Test a fake image."""
        os_stat.return_value = Mock(st_blocks=2)

        with tempfile.NamedTemporaryFile("w") as f:
            # Create a fake image.
            f.write("MY FAKE IMAGE")
            f.flush()

            # Run the task.
            configuration = LiveImageConfigurationData()
            configuration.url = "file://" + f.name

            task = SetUpLocalImageSourceTask(configuration)
            result = task.run()

            # Check the result.
            self.assertIsInstance(result, SetupImageResult)
            self.assertEqual(result, SetupImageResult(3072))