Beispiel #1
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 _create_blender_task(self, dir_manager):

        definition = RenderingTaskDefinition()
        definition.options = BlenderRendererOptions()
        definition.task_id = "deadbeef"
        definition.task_type = "Blender"

        task_file_name = os.path.join(self.path, 'task_file.gt')

        with open(task_file_name, 'wb') as task_file:
            task_file.write(jsonpickle.dumps(definition))

        return task_file_name