1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
# SPDX-License-Identifier: Apache-2.0
# Copyright Contributors to the OpenTimelineIO project
"""Test cases to verify examples used in the OTIO documentation."""
import os
import unittest
import opentimelineio as otio
SAMPLE_DATA_DIR = os.path.join(os.path.dirname(__file__), "sample_data")
CLIP_EXAMPLE_PATH = os.path.join(SAMPLE_DATA_DIR, "clip_example.otio")
class DocTester(unittest.TestCase):
def test_clip(self):
timeline = otio.adapters.read_from_file(CLIP_EXAMPLE_PATH)
track = timeline.tracks[0]
gapA, clip, transition, gapB = track[:]
self.assertEqual(
otio.opentime.RationalTime(19, 24),
track.duration()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(0, 24),
duration=otio.opentime.RationalTime(19, 24)
),
track.trimmed_range()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(0, 24),
duration=otio.opentime.RationalTime(19, 24)
),
track.available_range()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(0, 24),
duration=otio.opentime.RationalTime(19, 24)
),
track.visible_range()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(8, 24),
duration=otio.opentime.RationalTime(3, 24)
),
track.trimmed_range_of_child(clip)
)
self.assertEqual(
(
None,
otio.opentime.RationalTime(1, 24)
),
track.handles_of_child(clip)
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(8, 24),
duration=otio.opentime.RationalTime(3, 24)
),
track.trimmed_range_of_child(clip)
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(8, 24),
duration=otio.opentime.RationalTime(3, 24)
),
track.range_of_child(clip)
)
self.assertEqual(
otio.opentime.RationalTime(8, 24),
gapA.duration()
)
self.assertEqual(
otio.opentime.RationalTime(3, 24),
clip.duration()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(8, 24),
duration=otio.opentime.RationalTime(3, 24)
),
clip.trimmed_range_in_parent()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(8, 24),
duration=otio.opentime.RationalTime(3, 24)
),
clip.range_in_parent()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(3, 24),
duration=otio.opentime.RationalTime(3, 24)
),
clip.trimmed_range()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(3, 24),
duration=otio.opentime.RationalTime(4, 24)
),
clip.visible_range()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(0, 24),
duration=otio.opentime.RationalTime(8, 24)
),
clip.available_range()
)
self.assertEqual(
otio.opentime.TimeRange(
start_time=otio.opentime.RationalTime(0, 24),
duration=otio.opentime.RationalTime(8, 24)
),
clip.media_reference.available_range
)
self.assertEqual(
otio.opentime.RationalTime(2, 24),
transition.in_offset
)
self.assertEqual(
otio.opentime.RationalTime(1, 24),
transition.out_offset
)
self.assertEqual(
otio.opentime.RationalTime(8, 24),
gapB.duration()
)
if __name__ == '__main__':
unittest.main()
|