Beispiel #1
0
    def test_load_task_definition(self):
        gui = self.gui.get_main_window()
        gui.ui = Mock()

        controller = TestRendererCustomizer.TestRC(gui, self.logic)

        assert isinstance(controller, RendererCustomizer)
        task_def = RenderingTaskDefinition()
        files = self.additional_dir_content([1, [2]])
        task_def.resources = files
        task_def.main_scene_file = files[2]
        self.logic.dir_manager.root_path = self.path
        controller.load_task_definition(task_def)
        assert task_def.resources == files[:2]
Beispiel #2
0
    def test_customizer(self, file_dialog_mock):
        self.logic.client = Mock()
        self.logic.client.config_desc = Mock()
        self.logic.client.config_desc.max_price = 0
        self.logic.client.get_config.return_value = self.logic.client.config_desc
        self.logic.dir_manager = Mock()
        self.logic.dir_manager.root_path = self.path
        self.logic.customizer = Mock()

        register_task_types(self.logic)
        customizer = NewTaskDialogCustomizer(self.gui.main_window, self.logic)
        self.assertIsInstance(customizer, NewTaskDialogCustomizer)

        definition = RenderingTaskDefinition()
        renderer = BlenderTaskTypeInfo(Mock(), Mock())
        assert renderer.name == "Blender"
        assert renderer.options is not None
        definition.task_type = renderer.name
        definition.options = Mock()
        definition.options.use_frames = False
        definition.options.compositing = False
        resources = self.additional_dir_content([3])
        definition.resources = set(resources)
        self.logic.customizer = Mock()
        self.logic.task_types[renderer.name] = renderer
        customizer.load_task_definition(definition)
        with self.assertRaises(TypeError):
            customizer.load_task_definition(None)
        self.assertEqual(len(definition.resources), 3)
        customizer.gui.ui.taskNameLineEdit.setText("NEW NAME")
        definition2 = customizer._query_task_definition()
        self.assertEqual(definition2.task_name, "NEW NAME")
        file_dialog_mock.getOpenFileName.return_value = "/abc/def/ghi"

        definition.task_type = "UNKNOWN"
        with self.assertLogs(logger, level="ERROR"):
            customizer._load_task_type(definition)

        options = Options()
        customizer.set_options(options)
        assert customizer.logic.options == options

        customizer._NewTaskDialogCustomizer__test_task_button_clicked()
        customizer.test_task_computation_finished(True, 103139)
        self.assertEqual(customizer.task_state.definition.estimated_memory, 103139)
        self.assertTrue(customizer.gui.ui.finishButton.isEnabled())
        customizer._show_add_resource_dialog()
        self.assertFalse(customizer.gui.ui.finishButton.isEnabled())

        customizer._open_options()
 def _get_frame_task(self, use_frames=True, num_tasks=3):
     files_ = self.additional_dir_content([3])
     rt = RenderingTaskDefinition()
     rt.options = FrameRendererOptions()
     rt.options.use_frames = use_frames
     rt.options.frames = list(range(6))
     rt.main_scene_file = files_[1]
     rt.output_format = "PNG"
     rt.output_file = files_[2]
     rt.resources = []
     rt.resolution = [800, 600]
     rt.timeout = 3600
     rt.subtask_timeout = 600
     rt.estimated_memory = 1000
     rt.max_price = 15
     task = FrameRenderingTaskMock(files_[0],
                                   owner=Node(node_name="ABC"),
                                   task_definition=rt,
                                   total_tasks=num_tasks,
                                   root_path=self.path)
     dm = DirManager(self.path)
     task.initialize(dm)
     return task