Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_serialize(self):
st = otio.schema.Stack(
name="test",
children=[otio.schema.Clip(name="testClip")]
)
encoded = otio.adapters.otio_json.write_to_string(st)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertIsOTIOEquivalentTo(st, decoded)
self.assertIsNotNone(decoded[0].parent())
def test_serialize(self):
trx = otio.schema.Transition(
name="AtoB",
transition_type="SMPTE.Dissolve",
metadata={
"foo": "bar"
}
)
encoded = otio.adapters.otio_json.write_to_string(trx)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertIsOTIOEquivalentTo(trx, decoded)
def test_metadata(self):
rt = otio.opentime.RationalTime(12, 24)
tl = otio.schema.Timeline("test_timeline", global_start_time=rt)
tl.metadata['foo'] = "bar"
self.assertEqual(tl.metadata['foo'], 'bar')
encoded = otio.adapters.otio_json.write_to_string(tl)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertIsOTIOEquivalentTo(tl, decoded)
self.assertEqual(tl.metadata, decoded.metadata)
def test_serialize_time(self):
rt = otio.opentime.RationalTime(15, 24)
encoded = otio.adapters.otio_json.write_to_string(rt)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertEqual(rt, decoded)
rt_dur = otio.opentime.RationalTime(10, 20)
tr = otio.opentime.TimeRange(rt, rt_dur)
encoded = otio.adapters.otio_json.write_to_string(tr)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertEqual(tr, decoded)
tt = otio.opentime.TimeTransform(rt, scale=1.5)
encoded = otio.adapters.otio_json.write_to_string(tt)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertEqual(tt, decoded)
def check_against_baseline(self, obj, testname):
baseline = baseline_reader.json_baseline(testname)
self.assertDictEqual(
baseline_reader.json_from_string(
otio.adapters.otio_json.write_to_string(obj)
),
baseline
)
baseline_data = otio.adapters.otio_json.read_from_string(
json.dumps(baseline)
)
if isinstance(baseline_data, dict):
raise TypeError("did not deserialize correctly")
self.assertJsonEqual(obj, baseline_data)
def test_serialize(self):
encoded = otio.adapters.otio_json.write_to_string(self.sc)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertIsOTIOEquivalentTo(self.sc, decoded)
def test_serialize(self):
encoded = otio.adapters.otio_json.write_to_string(self.gen)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertIsOTIOEquivalentTo(self.gen, decoded)
def test_serialize_timeline(self):
clip = otio.schema.Clip(
name="test_clip",
media_reference=otio.schema.MissingReference()
)
tl = otio.schema.timeline_from_clips([clip])
encoded = otio.adapters.otio_json.write_to_string(tl)
decoded = otio.adapters.otio_json.read_from_string(encoded)
self.assertIsOTIOEquivalentTo(tl, decoded)
string2 = otio.adapters.otio_json.write_to_string(decoded)
self.assertEqual(encoded, string2)
or thing in (
otio.opentime.RationalTime,
otio.opentime.TimeRange,
otio.opentime.TimeTransform,
)
)
]
# serialize/deserialize the classes to capture their serialized parameters
model = {}
for cl in serializeable_classes:
if cl in SKIP_CLASSES:
continue
model[cl] = {}
field_dict = json.loads(otio.adapters.otio_json.write_to_string(cl()))
for k in field_dict.keys():
if k in SKIP_KEYS:
continue
for fetcher in PROP_FETCHERS:
try:
model[cl][k] = fetcher(cl, k)
break
except AttributeError:
pass
else:
sys.stderr.write("ERROR: could not fetch property: {}".format(k))
# Stashing the OTIO_SCHEMA back into the dictionary since the
# documentation uses this information in its header.
model[cl]["OTIO_SCHEMA"] = field_dict["OTIO_SCHEMA"]