示例#1
0
    def set_up_sources_task_test(self):
        """Test task to set up installation sources."""
        called_position = []

        def save_position(name):
            called_position.append(name)
            return DEFAULT

        set_up_task1 = create_autospec(Task)
        set_up_task2 = create_autospec(Task)
        set_up_task3 = create_autospec(Task)

        set_up_task1.run_with_signals.side_effect = lambda: save_position("task1")
        set_up_task2.run_with_signals.side_effect = lambda: save_position("task2")
        set_up_task3.run_with_signals.side_effect = lambda: save_position("task3")

        source1 = create_autospec(PayloadSourceBase)
        source2 = create_autospec(PayloadSourceBase)

        source1.set_up_with_tasks.side_effect = lambda: save_position("source1")
        source1.set_up_with_tasks.return_value = [set_up_task1, set_up_task2]
        source2.set_up_with_tasks.side_effect = lambda: save_position("source2")
        source2.set_up_with_tasks.return_value = [set_up_task3]

        task = SetUpSourcesTask([source1, source2])

        task.run()

        source1.set_up_with_tasks.assert_called_once()
        source2.set_up_with_tasks.assert_called_once()
        set_up_task1.run_with_signals.assert_called_once()
        set_up_task2.run_with_signals.assert_called_once()
        set_up_task3.run_with_signals.assert_called_once()
        self.assertEqual(["source1", "task1", "task2", "source2", "task3"], called_position)
示例#2
0
    def set_up_sources_with_task(self):
        """Set up installation sources."""
        self._check_source_availability("Set up source failed - source is not set!")

        task = SetUpSourcesTask(self._sources)
        task.succeeded_signal.connect(lambda: self.set_required_space(self._get_required_space()))

        return task
示例#3
0
    def set_up_sources_task_with_exception_test(self):
        """Test task to set up installation sources which raise exception."""
        set_up_task1 = create_autospec(Task)
        set_up_task2 = create_autospec(Task)
        set_up_task3 = create_autospec(Task)

        set_up_task2.run_with_signals.side_effect = SourceSetupError("task2 error")

        source1 = create_autospec(PayloadSourceBase)
        source2 = create_autospec(PayloadSourceBase)

        source1.set_up_with_tasks.return_value = [set_up_task1, set_up_task2]
        source2.set_up_with_tasks.return_value = [set_up_task3]

        task = SetUpSourcesTask([source1, source2])

        with self.assertRaises(SourceSetupError):
            task.run()

        set_up_task1.run_with_signals.assert_called_once()
        set_up_task2.run_with_signals.assert_called_once()
        set_up_task3.run_with_signals.assert_not_called()
示例#4
0
文件: dnf.py 项目: dvdhrm/anaconda
 def set_up_sources_with_task(self):
     """Set up installation sources."""
     # FIXME: Move the implementation to the base class.
     return SetUpSourcesTask(self._sources)
示例#5
0
    def set_up_sources_task_without_sources_test(self):
        """Test task to set up installation sources without sources set."""
        task = SetUpSourcesTask([])

        with self.assertRaises(SourceSetupError):
            task.run()
    def test_set_up_sources_task_without_sources(self):
        """Test task to set up installation sources without sources set."""
        task = SetUpSourcesTask([])

        with pytest.raises(SourceSetupError):
            task.run()
示例#7
0
 def set_up_sources_with_task(self):
     """Set up installation sources."""
     return SetUpSourcesTask(self.sources)