Skip to content
Permalink
Browse files

Fix bugs revealed by or related to code coverage. (#298)

* Omit things that don't get tested from code coverage.
* Add tests for error cases in the media linker and fix some bugs.
* Add a unit test for search path resolution.
* More unit tests in serializable collection.
* Rewrite unit test to use 'with' statement.
  • Loading branch information...
ssteinbach committed Jul 27, 2018
1 parent 6650017 commit 5b35e3762d9c348c85ed22327188a1d3fc498202
@@ -16,3 +16,9 @@ comment:
layout: "reach, diff, flags, files, footer"
behavior: default
require_changes: no

ignore:
- "opentimelineio_contrib/adapters/tests/test_rvsession.py"
- "opentimelineio_contrib/adapters/tests/test_maya_sequencer.py"
- "opentimelineio_contrib/adapters/tests/test_burnins.py"
- "opentimelineio_contrib/adapters/burnins.py"
@@ -83,3 +83,7 @@ class MisconfiguredPluginError(OTIOError):

class CannotTrimTransitionsError(OTIOError):
pass


class NoDefaultMediaLinkerError(OTIOError):
pass
@@ -100,7 +100,7 @@ def from_name(self, name, kind_list="adapters"):
if name == thing.name:
return thing

raise NotImplementedError(
raise exceptions.NotSupportedError(
"Could not find plugin: '{}' in kind_list: '{}'."
" options: {}".format(
name,
@@ -23,6 +23,7 @@
#
import unittest
import os
import tempfile

import opentimelineio as otio
import baseline_reader
@@ -189,6 +190,15 @@ def test_find_adapter_by_name(self):
"path"
)

def test_find_manifest_by_environment_variable(self):
# write the file into a temp dir
suffix = ".plugin_manifest.json"
with tempfile.NamedTemporaryFile(suffix=suffix) as fpath:
os.environ['OTIO_PLUGIN_MANIFEST_PATH'] = fpath.name + ':foo'
otio.adapters.write_to_file(self.man, fpath.name, 'otio_json')
result = otio.plugins.manifest.load_manifest()
self.assertEqual(result.media_linkers[0].name, "example")


if __name__ == '__main__':
unittest.main()
@@ -94,3 +94,18 @@ def test_serialize(self):
repr(self.mln.filepath)
)
)

def test_available_media_linker_names(self):
# for not just assert that it returns a non-empty list
self.assertTrue(otio.media_linker.available_media_linker_names())

def test_default_media_linker(self):
os.environ['OTIO_DEFAULT_MEDIA_LINKER'] = 'foo'
self.assertEqual(otio.media_linker.default_media_linker(), 'foo')
with self.assertRaises(otio.exceptions.NoDefaultMediaLinkerError):
del os.environ['OTIO_DEFAULT_MEDIA_LINKER']
otio.media_linker.default_media_linker()

def test_from_name_fail(self):
with self.assertRaises(otio.exceptions.NotSupportedError):
otio.media_linker.from_name("should not exist")
@@ -50,6 +50,21 @@ def test_iterable(self):
self.assertEqual([i for i in self.sc], self.children)
self.assertEqual(len(self.sc), 2)

# test recursive iteration
sc = otio.schema.SerializableCollection(
name="parent",
children=[self.sc]
)

self.assertEqual(len(list(sc.each_clip())), 1)

# test deleting an item
tmp = self.sc[0]
del self.sc[0]
self.assertEqual(len(self.sc), 1)
self.sc[0] = tmp
self.assertEqual(self.sc[0], tmp)

def test_serialize(self):
encoded = otio.adapters.otio_json.write_to_string(self.sc)
decoded = otio.adapters.otio_json.read_from_string(encoded)

0 comments on commit 5b35e37

Please sign in to comment.
You can’t perform that action at this time.