def test_presets(self):
        tdf = RenderingTaskDefinition()
        tdf.total_subtasks = 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["total_subtasks"] == 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.total_subtasks == 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.total_subtasks == 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"
예제 #2
0
    def test_calculate_total(self):
        definition = RenderingTaskDefinition()
        definition.optimize_total = True
        builder = RenderingTaskBuilder(root_path=self.path,
                                       dir_manager=DirManager(self.path),
                                       node_name="SOME NODE NAME",
                                       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.total_subtasks = 18
        assert builder._calculate_total(defaults) == 18

        definition.total_subtasks = 2
        with self.assertLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 17

        definition.total_subtasks = 3
        with self.assertNoLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 3

        definition.total_subtasks = 34
        with self.assertLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 17

        definition.total_subtasks = 33
        with self.assertNoLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 33
    def test_calculate_total(self):
        definition = RenderingTaskDefinition()
        definition.optimize_total = True
        definition.total_subtasks = 12
        definition.options = FrameRendererOptions()
        definition.options.use_frames = True
        definition.options.frames = range(1, 7)
        builder = FrameRenderingTaskBuilder(root_path=self.path, dir_manager=DirManager(self.path),
                                            node_name="SOME NODE NAME", task_definition=definition)

        class Defaults(object):
            def __init__(self, default_subtasks, min_subtasks, max_subtasks):
                self.default_subtasks = default_subtasks
                self.min_subtasks = min_subtasks
                self.max_subtasks = max_subtasks

        defaults = Defaults(13, 3, 33)
        assert builder._calculate_total(defaults) == 6

        definition.options.use_frames = False
        assert builder._calculate_total(defaults) == 13

        definition.optimize_total = False
        assert builder._calculate_total(defaults) == 12

        definition.total_subtasks = 2
        assert builder._calculate_total(defaults) == 13

        definition.total_subtasks = 3
        assert builder._calculate_total(defaults) == 3

        definition.total_subtasks = 34
        assert builder._calculate_total(defaults) == 13

        definition.total_subtasks = 33
        assert builder._calculate_total(defaults) == 33

        definition.total_subtasks = 6
        definition.options.use_frames = True
        with self.assertNoLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 6

        definition.total_subtasks = 3
        with self.assertNoLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 3

        definition.total_subtasks = 12
        with self.assertNoLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 12

        definition.total_subtasks = 4
        with self.assertLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 3

        definition.total_subtasks = 13
        with self.assertLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 12

        definition.total_subtasks = 17
        with self.assertLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 12

        definition.total_subtasks = 18
        with self.assertNoLogs(logger, level="WARNING"):
            assert builder._calculate_total(defaults) == 18