def test_disable_blur(self): op = ipoverrides.IpOverrides(None) op._disable_blur = True self.assertTrue(op.disable_blur) op = ipoverrides.IpOverrides(None) op._disable_blur = False op.disable_blur = True self.assertTrue(op._disable_blur)
def test_bucket_size(self): op = ipoverrides.IpOverrides(None) op._bucket_size = 16 self.assertEqual(op.bucket_size, 16) op = ipoverrides.IpOverrides(None) op._bucket_size = 8 op.bucket_size = 16 self.assertEqual(op._bucket_size, 16)
def test_disable_aovs(self): op = ipoverrides.IpOverrides(None) op._disable_aovs = True self.assertTrue(op.disable_aovs) op = ipoverrides.IpOverrides(None) op._disable_aovs = False op.disable_aovs = True self.assertTrue(op._disable_aovs)
def test_sample_scale(self): op = ipoverrides.IpOverrides(None) op._sample_scale = 0.5 self.assertEqual(op.sample_scale, 0.5) op = ipoverrides.IpOverrides(None) op._sample_scale = 1 op.sample_scale = 0.5 self.assertEqual(op._sample_scale, 0.5)
def test_transparent_samples(self): op = ipoverrides.IpOverrides(None) op._transparent_samples = 4 self.assertEqual(op.transparent_samples, 4) op = ipoverrides.IpOverrides(None) op._transparent_samples = 1 op.transparent_samples = 4 self.assertEqual(op._transparent_samples, 4)
def test_disable_subd(self): op = ipoverrides.IpOverrides(None) op._disable_subd = True self.assertTrue(op.disable_subd) op = ipoverrides.IpOverrides(None) op._disable_subd = False op.disable_subd = True self.assertTrue(op._disable_subd)
def test_disable_matte(self): op = ipoverrides.IpOverrides(None) op._disable_matte = True self.assertTrue(op.disable_matte) op = ipoverrides.IpOverrides(None) op._disable_matte = False op.disable_matte = True self.assertTrue(op._disable_matte)
def test_disable_displacement(self): op = ipoverrides.IpOverrides(None) op._disable_displacement = True self.assertTrue(op.disable_displacement) op = ipoverrides.IpOverrides(None) op._disable_displacement = False op.disable_displacement = True self.assertTrue(op._disable_displacement)
def test_disable_deep(self): op = ipoverrides.IpOverrides(None) op._disable_deep = True self.assertTrue(op.disable_deep) op = ipoverrides.IpOverrides(None) op._disable_deep = False op.disable_deep = True self.assertTrue(op._disable_deep)
def test_filterMaterial_no_disable(self, mock_set): op = ipoverrides.IpOverrides(None) op._disable_displacement = False op.filterMaterial() mock_set.assert_not_called()
def _create(prop_map=None, as_properties=False): """Function which instantiates the operation. :param prop_map: Map of property name:values to set. :type prop_map: dict :param as_properties: Whether or not to set the values as properties :type as_properties: bool :return: An basic instantiated IpOverrides object. :rtype: ipoverrides.IpOverrides """ op = ipoverrides.IpOverrides(None) if prop_map is None: prop_map = {} values = copy.deepcopy(_DEFAULTS) values.update(prop_map) for key, value in values.items(): if as_properties: if isinstance(value, type): prop = mocker.PropertyMock(spec=value) else: prop = mocker.PropertyMock(return_value=value) setattr(type(op), key, prop) else: setattr(op, "_{}".format(key), value) return op
def test_filterPlane_noop(self, mock_get, mock_set): op = ipoverrides.IpOverrides(None) op._disable_aovs = False op.filterPlane() mock_get.assert_not_called() mock_set.assert_not_called()
def test_process_parsed_args_None(self): namespace = argparse.Namespace() namespace.ip_res_scale = None namespace.ip_sample_scale = None namespace.ip_bucket_size = None namespace.ip_transparent_samples = None namespace.ip_disable_aovs = False namespace.ip_disable_blur = False namespace.ip_disable_deep = False namespace.ip_disable_displacement = False namespace.ip_disable_matte = False namespace.ip_disable_subd = False namespace.ip_disable_tilecallback = False op = ipoverrides.IpOverrides(None) op._res_scale = 0.5 op._sample_scale = 0.75 op._bucket_size = 16 op._transparent_samples = 3 op._disable_aovs = False op._disable_blur = False op._disable_deep = False op._disable_displacement = False op._disable_matte = False op._disable_subd = False op._disable_tilecallback = False op.process_parsed_args(namespace) self.assertEquals(op.res_scale, 0.5) self.assertEquals(op.sample_scale, 0.75) self.assertEquals(op.bucket_size, 16) self.assertEquals(op.transparent_samples, 3)
def test_filterMaterial_disable_displacement(self, mock_set): op = ipoverrides.IpOverrides(None) op._disable_displacement = True op.filterMaterial() mock_set.assert_called_with("object:displace", [])
def test_filterInstance_noop(self, mock_set): op = ipoverrides.IpOverrides(None) op._disable_displacement = False op._disable_subd = False op._disable_matte = False op.filterInstance() mock_set.assert_not_called()
def test_filterInstance_disable_subd(self, mock_set): op = ipoverrides.IpOverrides(None) op._disable_displacement = False op._disable_subd = True op._disable_matte = False op.filterInstance() mock_set.assert_called_with("object:rendersubd", 0)
def test_filterPlane_disable_aovs_Cf_Af(self, mock_get, mock_set): mock_get.return_value = "Cf+Af" op = ipoverrides.IpOverrides(None) op._disable_aovs = True op.filterPlane() mock_set.assert_not_called()
def test_filterPlane_disable_aovs_Cf(self, mock_get, mock_set): mock_get.return_value = "Cf" op = ipoverrides.IpOverrides(None) op._disable_aovs = True op.filterPlane() mock_set.assert_called_with("plane:disable", 1)
def test_filterCamera_disable_tilecallback(self, mock_set): op = ipoverrides.IpOverrides(None) op._res_scale = None op._sample_scale = None op._bucket_size = None op._disable_blur = False op._disable_deep = False op._disable_tilecallback = True op._transparent_samples = None op.filterCamera() mock_set.assert_called_with("render:tilecallback", "")
def test_filterCamera_transparent_samples(self, mock_set): op = ipoverrides.IpOverrides(None) op._res_scale = None op._sample_scale = None op._bucket_size = None op._disable_blur = False op._disable_deep = False op._disable_tilecallback = False op._transparent_samples = 3 op.filterCamera() mock_set.assert_any_call("image:transparentsamples", 3)
def test_filterCamera_disable_blur(self, mock_set): op = ipoverrides.IpOverrides(None) op._res_scale = None op._sample_scale = None op._bucket_size = None op._disable_blur = True op._disable_deep = False op._disable_tilecallback = False op._transparent_samples = None op.filterCamera() mock_set.has_calls([ call("renderer:blurquality", 0), call("renderer:rayblurquality", 0) ])
def test___init__(self): mock_manager = MagicMock(spec=PyFilterManager) op = ipoverrides.IpOverrides(mock_manager) self.assertEqual(op._data, {}) self.assertEqual(op._manager, mock_manager) self.assertIsNone(op._bucket_size) self.assertFalse(op._disable_aovs) self.assertFalse(op._disable_blur) self.assertFalse(op._disable_deep) self.assertFalse(op._disable_displacement) self.assertFalse(op._disable_matte) self.assertFalse(op._disable_subd) self.assertIsNone(op._res_scale) self.assertIsNone(op._sample_scale) self.assertIsNone(op._transparent_samples)
def test_filterInstance_disable_matte_matte_object(self, mock_set, mock_get): op = ipoverrides.IpOverrides(None) op._disable_displacement = False op._disable_subd = False op._disable_matte = True values = { "object:matte": True, "object:phantom": False, } mock_get.side_effect = lambda name: values.get(name) op.filterInstance() mock_get.assert_called_with("object:matte") mock_set.assert_called_with("object:renderable", False)
def test___init__(self, mocker): """Test object initialization.""" mock_super_init = mocker.patch.object(ipoverrides.PyFilterOperation, "__init__") mock_manager = mocker.MagicMock(spec=PyFilterManager) op = ipoverrides.IpOverrides(mock_manager) mock_super_init.assert_called_with(mock_manager) assert op._bucket_size is None assert not op._disable_aovs assert not op._disable_blur assert not op._disable_deep assert not op._disable_displacement assert not op._disable_matte assert not op._disable_subd assert op._res_scale is None assert op._sample_scale is None assert op._transparent_samples is None
def test_filterCamera_sample_scale(self, mock_get, mock_set, mock_scale): op = ipoverrides.IpOverrides(None) op._res_scale = None op._sample_scale = 0.5 op._bucket_size = None op._disable_blur = False op._disable_deep = False op._disable_tilecallback = False op._transparent_samples = None source_samples = [10, 10] target_samples = [5, 5] mock_get.return_value = source_samples mock_scale.return_value = target_samples op.filterCamera() mock_get.assert_called_with("image:samples") mock_scale.assert_called_with(source_samples, 0.5) mock_set.assert_called_with("image:samples", target_samples)
def test_filterInstance_disable_matte_noop(self, mock_set, mock_get): op = ipoverrides.IpOverrides(None) op._disable_displacement = False op._disable_subd = False op._disable_matte = True values = { "object:matte": False, "object:phantom": False, "object:surface": "opdef:/Shop/v_thing" } mock_get.side_effect = lambda name: values.get(name) op.filterInstance() mock_get.assert_has_calls([ call("object:matte"), call("object:phantom"), call("object:surface") ]) mock_set.assert_not_called()
def test_should_run(self, mock_get): op = ipoverrides.IpOverrides(None) op._res_scale = None op._sample_scale = None op._bucket_size = None op._transparent_samples = None op._disable_aovs = False op._disable_blur = False op._disable_deep = False op._disable_displacement = False op._disable_matte = False op._disable_subd = False op._disable_tilecallback = False self.assertFalse(op.should_run()) # Can't run if something is set but not ip. op.res_scale = 0.5 self.assertFalse(op.should_run()) op.res_scale = None # Can't run if ip but nothing else is set. mock_get.return_value = "ip" self.assertFalse(op.should_run()) op.res_scale = 0.5 self.assertTrue(op.should_run()) op.res_scale = None op.sample_scale = 0.5 self.assertTrue(op.should_run()) op.sample_scale = None op.disable_blur = True self.assertTrue(op.should_run()) op.disable_blur = False op.disable_aovs = True self.assertTrue(op.should_run()) op.disable_aovs = False op.disable_displacement = True self.assertTrue(op.should_run()) op.disable_displacement = False op.disable_matte = True self.assertTrue(op.should_run()) op.disable_matte = False op.disable_subd = True self.assertTrue(op.should_run()) op.disable_subd = False op.disable_tilecallback = True self.assertTrue(op.should_run()) op.disable_tilecallback = False op.bucket_size = 16 self.assertTrue(op.should_run()) op.bucket_size = None op.transparent_samples = 2 self.assertTrue(op.should_run()) op.transparent_samples = None