diff --git a/tests/test_clip.py b/tests/test_clip.py index 92d08f3457..8eef333ea6 100644 --- a/tests/test_clip.py +++ b/tests/test_clip.py @@ -145,6 +145,11 @@ def test_available_image_bounds(self): self.assertEqual(16.0, cl.available_image_bounds.max.x) self.assertEqual(9.0, cl.available_image_bounds.max.y) + # test range exceptions + cl.media_reference.available_image_bounds = None + with self.assertRaises(otio.exceptions.CannotComputeAvailableRangeError): + cl.available_range() + def test_ref_default(self): cl = otio.schema.Clip() self.assertIsOTIOEquivalentTo( diff --git a/tests/test_effect.py b/tests/test_effect.py index 5bf61ade2a..9e615695b4 100644 --- a/tests/test_effect.py +++ b/tests/test_effect.py @@ -62,8 +62,18 @@ def test_str(self): ) ) + def test_setters(self): + ef = otio.schema.Effect( + name="blur it", + effect_name="blur", + metadata={"foo": "bar"} + ) + self.assertEqual(ef.effect_name, "blur") + ef.effect_name = "flop" + self.assertEqual(ef.effect_name, "flop") + -class TestLinearTimeWarp(unittest.TestCase): +class TestLinearTimeWarp(unittest.TestCase, otio_test_utils.OTIOAssertions): def test_cons(self): ef = otio.schema.LinearTimeWarp("Foo", 2.5, {'foo': 'bar'}) self.assertEqual(ef.effect_name, "LinearTimeWarp") @@ -71,6 +81,18 @@ def test_cons(self): self.assertEqual(ef.time_scalar, 2.5) self.assertEqual(ef.metadata, {"foo": "bar"}) + def test_serialize(self): + ef = otio.schema.LinearTimeWarp("Foo", 2.5, {'foo': 'bar'}) + encoded = otio.adapters.otio_json.write_to_string(ef) + decoded = otio.adapters.otio_json.read_from_string(encoded) + self.assertIsOTIOEquivalentTo(ef, decoded) + + def test_setters(self): + ef = otio.schema.LinearTimeWarp("Foo", 2.5, {'foo': 'bar'}) + self.assertEqual(ef.time_scalar, 2.5) + ef.time_scalar = 5.0 + self.assertEqual(ef.time_scalar, 5.0) + class TestFreezeFrame(unittest.TestCase): def test_cons(self): diff --git a/tests/test_item.py b/tests/test_item.py index fbbf1b704a..8717f38922 100755 --- a/tests/test_item.py +++ b/tests/test_item.py @@ -235,6 +235,13 @@ def test_metadata(self): self.assertIsOTIOEquivalentTo(it, decoded) self.assertEqual(decoded.metadata["foo"], it.metadata["foo"]) + foo = it.metadata.pop("foo") + self.assertEqual(foo, "bar") + foo = it.metadata.pop("foo", "default") + self.assertEqual(foo, "default") + with self.assertRaises(KeyError): + it.metadata.pop("foo") + def test_add_effect(self): tr = otio.opentime.TimeRange( duration=otio.opentime.RationalTime(10, 1) diff --git a/tests/test_transition.py b/tests/test_transition.py index 1ce3f52158..fdf78c1c1a 100644 --- a/tests/test_transition.py +++ b/tests/test_transition.py @@ -74,6 +74,91 @@ def test_stringify(self): ) ) + def test_setters(self): + trx = otio.schema.Transition( + name="AtoB", + transition_type="SMPTE.Dissolve", + metadata={ + "foo": "bar" + } + ) + self.assertEqual(trx.transition_type, "SMPTE.Dissolve") + trx.transition_type = "EdgeWipe" + self.assertEqual(trx.transition_type, "EdgeWipe") + + def test_parent_range(self): + timeline = otio.schema.Timeline( + tracks=[ + otio.schema.Track( + name="V1", + children=[ + otio.schema.Clip( + name="A", + source_range=otio.opentime.TimeRange( + start_time=otio.opentime.RationalTime( + value=1, + rate=30 + ), + duration=otio.opentime.RationalTime( + value=50, + rate=30 + ) + ) + ), + otio.schema.Transition( + in_offset=otio.opentime.RationalTime( + value=7, + rate=30 + ), + out_offset=otio.opentime.RationalTime( + value=10, + rate=30 + ), + ), + otio.schema.Clip( + name="B", + source_range=otio.opentime.TimeRange( + start_time=otio.opentime.RationalTime( + value=100, + rate=30 + ), + duration=otio.opentime.RationalTime( + value=50, + rate=30 + ) + ) + ), + ] + ) + ] + ) + trx = timeline.tracks[0][1] + time_range = otio.opentime.TimeRange(otio.opentime.RationalTime(43, 30), + otio.opentime.RationalTime(17, 30)) + + self.assertEqual(time_range, + trx.range_in_parent()) + + self.assertEqual(time_range, + trx.trimmed_range_in_parent()) + + trx = otio.schema.Transition( + in_offset=otio.opentime.RationalTime( + value=7, + rate=30 + ), + out_offset=otio.opentime.RationalTime( + value=10, + rate=30 + ), + ) + + with self.assertRaises(otio.exceptions.NotAChildError): + trx.range_in_parent() + + with self.assertRaises(otio.exceptions.NotAChildError): + trx.trimmed_range_in_parent() + if __name__ == '__main__': unittest.main()