|
2 | 2 | # Copyright Contributors to the OpenTimelineIO project
|
3 | 3 |
|
4 | 4 | import copy
|
| 5 | +import json |
5 | 6 | import unittest
|
6 | 7 |
|
7 | 8 | import opentimelineio._otio
|
8 | 9 | import opentimelineio.core._core_utils
|
| 10 | +import opentimelineio.core |
| 11 | +import opentimelineio.opentime |
9 | 12 |
|
10 | 13 |
|
11 | 14 | class AnyDictionaryTests(unittest.TestCase):
|
@@ -242,3 +245,52 @@ def test_copy(self):
|
242 | 245 | deepcopied = copy.deepcopy(v)
|
243 | 246 | self.assertIsNot(v, deepcopied)
|
244 | 247 | self.assertIsNot(v[2], deepcopied[2])
|
| 248 | + |
| 249 | + |
| 250 | +class ConvertToPython(unittest.TestCase): |
| 251 | + def test_SerializableObject(self): |
| 252 | + so = opentimelineio.core.SerializableObjectWithMetadata(name="asd") |
| 253 | + so.metadata["key1"] = opentimelineio.core.Composition() |
| 254 | + |
| 255 | + d = so.to_dict() |
| 256 | + self.assertTrue(isinstance(d, dict)) |
| 257 | + json.dumps(d) |
| 258 | + |
| 259 | + def test_AnyDictionary(self): |
| 260 | + ad = opentimelineio._otio.AnyDictionary() |
| 261 | + ad["my key"] = opentimelineio.core.Composable() |
| 262 | + |
| 263 | + d = ad.to_dict() |
| 264 | + self.assertTrue(isinstance(d, dict)) |
| 265 | + json.dumps(d) |
| 266 | + |
| 267 | + def test_AnyVector(self): |
| 268 | + av = opentimelineio._otio.AnyVector() |
| 269 | + av.append(1) |
| 270 | + av.append(opentimelineio._otio.AnyDictionary()) |
| 271 | + |
| 272 | + l = av.to_list() |
| 273 | + self.assertTrue(isinstance(l, list)) |
| 274 | + self.assertEqual(l, [1, {}]) |
| 275 | + json.dumps(l) |
| 276 | + |
| 277 | + def test_RationalTime(self): |
| 278 | + rt = opentimelineio.opentime.RationalTime() |
| 279 | + |
| 280 | + d = rt.to_dict() |
| 281 | + self.assertTrue(isinstance(d, dict)) |
| 282 | + json.dumps(d) |
| 283 | + |
| 284 | + def test_TimeRange(self): |
| 285 | + tr = opentimelineio.opentime.TimeRange() |
| 286 | + |
| 287 | + d = tr.to_dict() |
| 288 | + self.assertTrue(isinstance(d, dict)) |
| 289 | + json.dumps(d) |
| 290 | + |
| 291 | + def test_TimeTransform(self): |
| 292 | + tt = opentimelineio.opentime.TimeTransform() |
| 293 | + |
| 294 | + d = tt.to_dict() |
| 295 | + self.assertTrue(isinstance(d, dict)) |
| 296 | + json.dumps(d) |
0 commit comments