def test_presets(self): tdf = RenderingTaskDefinition() tdf.subtasks_count = 12 tdf.options = "Some option" tdf.optimize_total = True tdf.verification_options = "Option" tdf.resolution = [1111, 2222] tdf.output_format = ".exr" preset = tdf.make_preset() assert len(preset) == 6 assert preset["subtasks_count"] == 12 assert preset["options"] == "Some option" assert preset["optimize_total"] assert preset["verification_options"] == "Option" assert preset["output_format"] == ".exr" assert preset["resolution"] == [1111, 2222] tdf2 = RenderingTaskDefinition() assert tdf2.subtasks_count == 0 assert tdf2.options is None assert not tdf2.optimize_total assert tdf2.verification_options is None assert tdf2.resolution == [0, 0] assert tdf2.output_format == "" tdf2.load_preset(preset) assert tdf2.subtasks_count == 12 assert tdf2.options == "Some option" assert tdf2.optimize_total assert tdf2.verification_options == "Option" assert tdf2.resolution == [1111, 2222] assert tdf2.output_format == ".exr"
def test_build(self): definition = RenderingTaskDefinition() definition.subtasks_count = 1 definition.options = BlenderRendererOptions() builder = BlenderRenderTaskBuilder(owner=Node(), task_definition=definition, dir_manager=DirManager( self.tempdir)) blender_task = builder.build() self.assertIsInstance(blender_task, BlenderRenderTask)
def test_calculate_total(self): definition = RenderingTaskDefinition() definition.optimize_total = True builder = RenderingTaskBuilder(owner=Node(node_name="node"), dir_manager=DirManager(self.path), task_definition=definition) class Defaults(object): def __init__(self, default_subtasks=13, min_subtasks=3, max_subtasks=33): self.default_subtasks = default_subtasks self.min_subtasks = min_subtasks self.max_subtasks = max_subtasks defaults = Defaults() assert builder._calculate_total(defaults) == 13 defaults.default_subtasks = 17 assert builder._calculate_total(defaults) == 17 definition.optimize_total = False definition.subtasks_count = 18 assert builder._calculate_total(defaults) == 18 definition.subtasks_count = 2 with self.assertLogs(logger_render, level="WARNING"): assert builder._calculate_total(defaults) == 17 definition.subtasks_count = 3 with self.assertNoLogs(logger_render, level="WARNING"): assert builder._calculate_total(defaults) == 3 definition.subtasks_count = 34 with self.assertLogs(logger_render, level="WARNING"): assert builder._calculate_total(defaults) == 17 definition.subtasks_count = 33 with self.assertNoLogs(logger_render, level="WARNING"): assert builder._calculate_total(defaults) == 33
def test_calculate_total(self): definition = RenderingTaskDefinition() definition.optimize_total = True definition.subtasks_count = 12 definition.options = FrameRendererOptions() definition.options.use_frames = True definition.options.frames = list(range(1, 7)) builder = FrameRenderingTaskBuilder(Node(node_name="node"), dir_manager=DirManager(self.path), task_definition=definition) defaults = RendererDefaults() # More subtasks than frames -> use frames count assert builder._calculate_total(defaults) == 6 definition.options.use_frames = False # Optimize total to default assert builder._calculate_total(defaults) == 20 definition.optimize_total = False # Don't optimize -> use subtasks_count assert builder._calculate_total(defaults) == 12 definition.subtasks_count = None # subtasks_count unknown -> use default assert builder._calculate_total(defaults) == 20 definition.subtasks_count = 0 # subtasks_count invalid -> use default assert builder._calculate_total(defaults) == 20 definition.subtasks_count = 1 # subtasks_count min assert builder._calculate_total(defaults) == 1 definition.subtasks_count = 51 # subtasks_count over max -> use default assert builder._calculate_total(defaults) == 20 definition.subtasks_count = 50 # subtasks_count max assert builder._calculate_total(defaults) == 50 definition.options.use_frames = True definition.subtasks_count = None with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 6 definition.subtasks_count = 0 with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 6 definition.subtasks_count = 1 with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 1 definition.subtasks_count = 2 with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 2 definition.subtasks_count = 3 with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 3 definition.subtasks_count = 6 with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 6 definition.subtasks_count = 12 with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 12 definition.subtasks_count = 4 with self.assertLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 3 definition.subtasks_count = 13 with self.assertLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 12 definition.subtasks_count = 17 with self.assertLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 12 definition.subtasks_count = 18 with self.assertNoLogs(logger, level="WARNING"): assert builder._calculate_total(defaults) == 18