Skip to content

Commit 7e862e6

Browse files
committed
added edit tests
Signed-off-by: Yingjie Wang <[email protected]>
1 parent e7972f4 commit 7e862e6

File tree

2 files changed

+121
-29
lines changed

2 files changed

+121
-29
lines changed

src/py-opentimelineio/opentimelineio/console/otiodiff/clipData.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def checkEdited(self, cA):
132132

133133
# clip duration longer
134134
elif(selfDur.value > cADur.value):
135-
self.note = "lengthened"
135+
self.note = "lengthened " + deltaFramesStr + " frames"
136136

137137
if(selfSourceStart.value == cASourceStart.value):
138138
self.note = "lengthened tail by " + deltaFramesStr + " frames"

tests/test_otiodiff.py

Lines changed: 120 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def test_check_same_if_move(self):
212212
clipDataB = ClipData(clipB, 1)
213213

214214
assert clipDataB.checkSame(clipDataA)
215-
assert clipDataB.note == "moved"
215+
assert clipDataB.note == "shifted laterally in track"
216216

217217
def test_check_not_same(self):
218218
# check that two clips with different names are not the same
@@ -315,8 +315,8 @@ def test_check_not_same3(self):
315315

316316
assert not clipDataB.checkSame(clipDataA)
317317
assert clipDataB.note is None
318-
319-
def test_check_Edited(self):
318+
319+
def test_check_edited_trimmed_head(self):
320320
# check for trim head/tail and lengthen head/tail
321321
clipA = otio.schema.Clip(
322322
name = "testName testTake",
@@ -332,8 +332,8 @@ def test_check_Edited(self):
332332
name = "testName testTake",
333333
media_reference = otio.core.MediaReference(
334334
available_range=otio.opentime.TimeRange(
335-
otio.opentime.RationalTime(10, 24),
336-
otio.opentime.RationalTime(90, 24))),
335+
otio.opentime.RationalTime(0, 24),
336+
otio.opentime.RationalTime(100, 24))),
337337
source_range = otio.opentime.TimeRange(
338338
otio.opentime.RationalTime(10, 24),
339339
otio.opentime.RationalTime(90, 24)),
@@ -346,9 +346,115 @@ def test_check_Edited(self):
346346

347347
clipDataA = ClipData(clipA, 1)
348348
clipDataB = ClipData(clipB, 1)
349+
350+
351+
assert clipDataB.checkEdited(clipDataA)
352+
print("note is:", clipDataB.note)
353+
assert clipDataB.note == "trimmed head by 10 frames"
354+
355+
def test_check_edited_trimmed_tail(self):
356+
# check for trim head/tail and lengthen head/tail
357+
clipA = otio.schema.Clip(
358+
name = "testName testTake",
359+
media_reference = otio.core.MediaReference(
360+
available_range=otio.opentime.TimeRange(
361+
otio.opentime.RationalTime(0, 24),
362+
otio.opentime.RationalTime(100, 24))),
363+
source_range = otio.opentime.TimeRange(
364+
otio.opentime.RationalTime(0, 24),
365+
otio.opentime.RationalTime(100, 24)),
366+
)
367+
clipB = otio.schema.Clip(
368+
name = "testName testTake",
369+
media_reference = otio.core.MediaReference(
370+
available_range=otio.opentime.TimeRange(
371+
otio.opentime.RationalTime(0, 24),
372+
otio.opentime.RationalTime(100, 24))),
373+
source_range = otio.opentime.TimeRange(
374+
otio.opentime.RationalTime(0, 24),
375+
otio.opentime.RationalTime(90, 24)),
376+
)
377+
trackA = otio.schema.Track()
378+
trackB = otio.schema.Track()
379+
380+
trackA.append(clipA)
381+
trackB.append(clipB)
382+
383+
clipDataA = ClipData(clipA, 1)
384+
clipDataB = ClipData(clipB, 1)
385+
386+
387+
assert clipDataB.checkEdited(clipDataA)
388+
assert clipDataB.note == "trimmed tail by 10 frames"
389+
390+
def test_check_edited_lengthened_head(self):
391+
# check for trim head/tail and lengthen head/tail
392+
clipA = otio.schema.Clip(
393+
name = "testName testTake",
394+
media_reference = otio.core.MediaReference(
395+
available_range=otio.opentime.TimeRange(
396+
otio.opentime.RationalTime(0, 24),
397+
otio.opentime.RationalTime(100, 24))),
398+
source_range = otio.opentime.TimeRange(
399+
otio.opentime.RationalTime(10, 24),
400+
otio.opentime.RationalTime(10, 24)),
401+
)
402+
clipB = otio.schema.Clip(
403+
name = "testName testTake",
404+
media_reference = otio.core.MediaReference(
405+
available_range=otio.opentime.TimeRange(
406+
otio.opentime.RationalTime(0, 24),
407+
otio.opentime.RationalTime(100, 24))),
408+
source_range = otio.opentime.TimeRange(
409+
otio.opentime.RationalTime(0, 24),
410+
otio.opentime.RationalTime(20, 24)),
411+
)
412+
trackA = otio.schema.Track()
413+
trackB = otio.schema.Track()
414+
415+
trackA.append(clipA)
416+
trackB.append(clipB)
417+
418+
clipDataA = ClipData(clipA, 1)
419+
clipDataB = ClipData(clipB, 1)
420+
421+
assert clipDataB.checkEdited(clipDataA)
422+
print("note:", clipDataB.note)
423+
assert clipDataB.note == "lengthened head by 10 frames"
424+
425+
def test_check_edited_lengthened_tail(self):
426+
# check for trim head/tail and lengthen head/tail
427+
clipA = otio.schema.Clip(
428+
name = "testName testTake",
429+
media_reference = otio.core.MediaReference(
430+
available_range=otio.opentime.TimeRange(
431+
otio.opentime.RationalTime(0, 24),
432+
otio.opentime.RationalTime(100, 24))),
433+
source_range = otio.opentime.TimeRange(
434+
otio.opentime.RationalTime(0, 24),
435+
otio.opentime.RationalTime(10, 24)),
436+
)
437+
clipB = otio.schema.Clip(
438+
name = "testName testTake",
439+
media_reference = otio.core.MediaReference(
440+
available_range=otio.opentime.TimeRange(
441+
otio.opentime.RationalTime(0, 24),
442+
otio.opentime.RationalTime(100, 24))),
443+
source_range = otio.opentime.TimeRange(
444+
otio.opentime.RationalTime(0, 24),
445+
otio.opentime.RationalTime(20, 24)),
446+
)
447+
trackA = otio.schema.Track()
448+
trackB = otio.schema.Track()
449+
450+
trackA.append(clipA)
451+
trackB.append(clipB)
452+
453+
clipDataA = ClipData(clipA, 1)
454+
clipDataB = ClipData(clipB, 1)
349455

350456
assert clipDataB.checkEdited(clipDataA)
351-
assert clipDataB.note == "trimmed 10 frames"
457+
assert clipDataB.note == "lengthened tail by 10 frames"
352458

353459
class TestGetDif(unittest.TestCase):
354460
def test_find_clones(self):
@@ -593,28 +699,14 @@ def test_sort_clones_clones_in_one_single_in_other(self):
593699
assert(len(clonesB) == 1), "Number of clones found in trackB doesn't match"
594700
assert(len(nonClonesB) == 2), "Number of non-clones found in trackB doesn't match"
595701

596-
# class TestMakeOtio(unittest.TestCase):
597-
# # Test the type parameter to makeTimelineOfType, but not the detailed results.
598-
# def test_make_timeline_type(self):
599-
# # SETUP
600-
# trackA = otio.schema.Track()
601-
# trackB = otio.schema.Track()
602-
# pass
603-
604-
# SortedClipDatas = namedtuple('VideoGroup', ['add', 'edit', 'same', 'delete'])
605-
# videoGroup = SortedClipDatas([], [], [], [])
606-
607-
# # EXERCISE
608-
# tlStack = makeOtio.makeTimelineOfType("stack", trackA, trackB, videoGroup)
609-
# tlInline = makeOtio.makeTimelineOfType("inline", trackA, trackB, videoGroup)
610-
# tlFull = makeOtio.makeTimelineOfType("full", trackA, trackB, videoGroup)
611-
# bogus = makeOtio.makeTimelineOfType("bogus", trackA, trackB, videoGroup)
612-
613-
# # VERIFY
614-
# assert(len(tlStack.tracks) == 6), "Number of tracks for stack display mode not matched"
615-
# assert(len(tlInline.tracks) == 2), "Number of tracks for inline display mode not matched"
616-
# assert(len(tlFull.tracks) == 5), "Number of tracks for full display mode not matched"
617-
# assert(bogus is None), "Should have been invalid result"
702+
# TODO: test case for timelines with unmatched track nums
703+
# test case for timeline with matched track nums
704+
705+
class TestMakeOtio(unittest.TestCase):
706+
# TODO: test sort clips
707+
708+
# test make track
709+
pass
618710

619711

620712
if __name__ == '__main__':

0 commit comments

Comments
 (0)