Skip to content

Commit

Permalink
Add unit tests for areas affected by the removal of the aaf adapter
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Reid <[email protected]>
  • Loading branch information
markreidvfx committed Jul 13, 2022
1 parent 403a51b commit 4fb04b0
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/test_clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
24 changes: 23 additions & 1 deletion tests/test_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,37 @@ 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")
self.assertEqual(ef.name, "Foo")
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):
Expand Down
7 changes: 7 additions & 0 deletions tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
85 changes: 85 additions & 0 deletions tests/test_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit 4fb04b0

Please sign in to comment.