Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 25 additions & 24 deletions contrib/opentimelineio_contrib/adapters/tests/test_rvsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,21 @@
"RV Adapter does not work in python 3."
)
class RVSessionAdapterReadTest(unittest.TestCase):
def setUp(self):
fd, self.tmp_path = tempfile.mkstemp(suffix=".rv", text=True)

# Close file descriptor to avoid leak. We only need the tmp_path.
os.close(fd)

def tearDown(self):
os.unlink(self.tmp_path)

def test_basic_rvsession_read(self):
timeline = otio.adapters.read_from_file(SCREENING_EXAMPLE_PATH)
tmp_path = tempfile.mkstemp(suffix=".rv", text=True)[1]

otio.adapters.write_to_file(timeline, tmp_path)
self.assertTrue(os.path.exists(tmp_path))
otio.adapters.write_to_file(timeline, self.tmp_path)

with open(tmp_path) as fo:
with open(self.tmp_path) as fo:
test_data = fo.read()

with open(BASELINE_PATH) as fo:
Expand All @@ -486,12 +493,11 @@ def test_basic_rvsession_read(self):

def test_transition_rvsession_read(self):
timeline = otio.adapters.read_from_file(TRANSITION_EXAMPLE_PATH)
tmp_path = tempfile.mkstemp(suffix=".rv", text=True)[1]

otio.adapters.write_to_file(timeline, tmp_path)
self.assertTrue(os.path.exists(tmp_path))
otio.adapters.write_to_file(timeline, self.tmp_path)
self.assertTrue(os.path.exists(self.tmp_path))

with open(tmp_path) as fo:
with open(self.tmp_path) as fo:
test_data = fo.read()

with open(BASELINE_TRANSITION_PATH) as fo:
Expand All @@ -503,16 +509,14 @@ def test_transition_rvsession_read(self):
def test_image_sequence_example(self):
# SETUP
timeline = otio.adapters.read_from_file(IMAGE_SEQUENCE_EXAMPLE_PATH)
tmp_path = tempfile.mkstemp(suffix=".rv", text=True)[1]

# EXERCISE
otio.adapters.write_to_file(timeline, tmp_path)
otio.adapters.write_to_file(timeline, self.tmp_path)

# VERIFY
self.assertTrue(os.path.exists(tmp_path))
self.assertTrue(os.path.getsize(tmp_path) > 0)
self.assertTrue(os.path.exists(self.tmp_path))

with open(tmp_path) as f:
with open(self.tmp_path) as f:
rv_session = f.read()

self.assertEqual(
Expand All @@ -525,13 +529,12 @@ def test_image_sequence_example(self):
def test_transition_rvsession_covers_entire_shots(self):
# SETUP
timeline = otio.adapters.read_from_string(SAMPLE_DATA, "otio_json")
tmp_path = tempfile.mkstemp(suffix=".rv", text=True)[1]

# EXERCISE
otio.adapters.write_to_file(timeline, tmp_path)
otio.adapters.write_to_file(timeline, self.tmp_path)

# VERIFY
with open(tmp_path, "r") as f:
with open(self.tmp_path, "r") as f:
rv_session = f.read()

self.assertEqual(rv_session.count('movie = "blank'), 1)
Expand All @@ -540,13 +543,12 @@ def test_transition_rvsession_covers_entire_shots(self):
def test_audio_video_tracks(self):
# SETUP
timeline = otio.adapters.read_from_string(AUDIO_VIDEO_SAMPLE_DATA, "otio_json")
tmp_path = tempfile.mkstemp(suffix=".rv", text=True)[1]

# EXERCISE
otio.adapters.write_to_file(timeline, tmp_path)
otio.adapters.write_to_file(timeline, self.tmp_path)

# VERIFY
self.assertTrue(os.path.exists(tmp_path))
self.assertTrue(os.path.exists(self.tmp_path))

audio_video_source = (
'string movie = '
Expand All @@ -555,7 +557,7 @@ def test_audio_video_tracks(self):
' "/path/to/audio.wav" ]'
)

with open(tmp_path, "r") as f:
with open(self.tmp_path, "r") as f:
rv_session = f.read()

self.assertEqual(rv_session.count("string movie"), 2)
Expand All @@ -568,13 +570,12 @@ def test_nested_stack(self):
NESTED_STACK_SAMPLE_DATA,
"otio_json"
)
tmp_path = tempfile.mkstemp(suffix=".rv", text=True)[1]

# EXERCISE
otio.adapters.write_to_file(timeline, tmp_path)
otio.adapters.write_to_file(timeline, self.tmp_path)

# VERIFY
self.assertTrue(os.path.exists(tmp_path))
self.assertTrue(os.path.exists(self.tmp_path))

audio_video_source = (
'string movie = '
Expand All @@ -586,7 +587,7 @@ def test_nested_stack(self):
'string movie = "/path/to/some/video.mov"'
)

with open(tmp_path, "r") as f:
with open(self.tmp_path, "r") as f:
rv_session = f.read()
self.assertEqual(rv_session.count(video_source), 2)
self.assertEqual(rv_session.count(audio_video_source), 2)
Expand Down