Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Christophe Morin <[email protected]>
  • Loading branch information
JeanChristopheMorinPerso committed Mar 9, 2024
1 parent b80a871 commit cf764ee
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/test_core_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
# Copyright Contributors to the OpenTimelineIO project

import copy
import json
import unittest

import opentimelineio._otio
import opentimelineio.core._core_utils
import opentimelineio.core
import opentimelineio.opentime


class AnyDictionaryTests(unittest.TestCase):
Expand Down Expand Up @@ -242,3 +245,52 @@ def test_copy(self):
deepcopied = copy.deepcopy(v)
self.assertIsNot(v, deepcopied)
self.assertIsNot(v[2], deepcopied[2])


class ConvertToPython(unittest.TestCase):
def test_SerializableObject(self):
so = opentimelineio.core.SerializableObjectWithMetadata(name="asd")
so.metadata["key1"] = opentimelineio.core.Composition()

d = so.to_dict()
self.assertTrue(isinstance(d, dict))
json.dumps(d)

def test_AnyDictionary(self):
ad = opentimelineio._otio.AnyDictionary()
ad["my key"] = opentimelineio.core.Composable()

d = ad.to_dict()
self.assertTrue(isinstance(d, dict))
json.dumps(d)

def test_AnyVector(self):
av = opentimelineio._otio.AnyVector()
av.append(1)
av.append(opentimelineio._otio.AnyDictionary())

l = av.to_list()
self.assertTrue(isinstance(l, list))
self.assertEqual(l, [1, {}])
json.dumps(l)

def test_RationalTime(self):
rt = opentimelineio.opentime.RationalTime()

d = rt.to_dict()
self.assertTrue(isinstance(d, dict))
json.dumps(d)

def test_TimeRange(self):
tr = opentimelineio.opentime.TimeRange()

d = tr.to_dict()
self.assertTrue(isinstance(d, dict))
json.dumps(d)

def test_TimeTransform(self):
tt = opentimelineio.opentime.TimeTransform()

d = tt.to_dict()
self.assertTrue(isinstance(d, dict))
json.dumps(d)

0 comments on commit cf764ee

Please sign in to comment.