def disabled__test_output_passing(self): """ Test that output registered in a pre-process is serialized to a ol:outputs file in the render layer. """ with TemporarySessionDirectory(): ol = outline.Outline("pre_test") # the render layer layer1 = TestA("test1") # the preprocess prelayer = outline.layer.LayerPreProcess(layer1) prelayer._execute = lambda frames: prelayer.add_output( "test", outline.io.FileSpec("/tmp/foo.#.exr")) # Add both to the outline ol.add_layer(layer1) ol.add_layer(prelayer) # setup for execute ol.setup() # now run the preprocess prelayer.execute(1000) # The file should exist. self.assertTrue(os.path.exists("%s/ol:outputs" % layer1.get_path())) # now run a single frame of the render layer and ensure that # the outputs are automatically loaded. layer1.execute(1000) self.assertEquals(1, len(layer1.get_outputs()))
def test_execute(self, systemMock): """Test execution of a frame.""" with TemporarySessionDirectory(): self.ol.setup() self.event.execute(1) systemMock.assert_has_calls([mock.call(['ps', 'aux'], frame=1)])
def testShellScript(self, systemMock): """Test a custom shell script layer""" # The script will be copied into the session directory so we have to create a dummy # session to use. layerName = 'arbitrary-layer' with TemporarySessionDirectory(), tempfile.NamedTemporaryFile() as scriptFile: scriptContents = '# !/bin/sh\necho zoom zoom zoom' with open(scriptFile.name, 'w') as fp: fp.write(scriptContents) outln = Outline() outln.setup() expectedSessionPath = outln.get_session().put_file( scriptFile.name, layer=layerName, rename='script') shellScript = ShellScript(layerName, script=scriptFile.name) shellScript.set_outline(outln) shellScript._setup() shellScript._execute(FrameSet('5-6')) with open(expectedSessionPath) as fp: sessionScriptContents = fp.read() self.assertEqual(scriptContents, sessionScriptContents) systemMock.assert_has_calls([mock.call(expectedSessionPath, frame=5)])
def test_get_set_path(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) path = '/tmp/foo.outline' ol.set_path(path) self.assertEquals(path, ol.get_path())
def test_get_set_name(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) name = 'foo_name' ol.set_name(name) self.assertEquals(name, ol.get_name())
def test_get_path(self): """Test that the layer session path is correct.""" with TemporarySessionDirectory(): self.assertRaises(outline.OutlineException, self.event.get_path) self.ol.setup() expectedPath = '%s/layers/%s' % (self.ol.get_session().get_path(), self.event.get_name()) self.assertEquals(expectedPath, self.event.get_path())
def testJsonFile(self, systemMock): """Load JSON from a file""" with open(os.path.join(JSON_DIR, 'shell.outline')) as fp: ol = load_json(fp.read()) with TemporarySessionDirectory(): ol.setup() ol.get_layer('shell_layer').execute('1000') systemMock.assert_has_calls([mock.call(['/bin/ls'], frame=1000)])
def test_dependency_creation(self): with TemporarySessionDirectory(): outline.Outline.current = None ol = outline.Outline('after_init') ol.add_layer(TestAfterInit('test')) ol.add_layer(TestB('testb', require='test')) ol.setup() # check the depend was setup properly self.assertEquals(1, len(ol.get_layer('testb').get_depends()))
def test_add_get_remove_layer(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) ol.add_layer(Shell("shell_command", cmd=["/bin/ls"])) self.assertEquals(2, len(ol.get_layers())) self.assertTrue(isinstance(ol.get_layer("shell_command"), Shell)) ol.remove_layer(ol.get_layer("shell_command")) self.assertEquals(1, len(ol.get_layers()))
def test_get_set_env(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) ol.set_env("ENV_1", "a") ol.set_env("ENV_2", "b", True) self.assertEquals(ol.get_env("ENV_1"), "a") self.assertFalse(ol.get_env()["ENV_1"][1]) self.assertEquals(ol.get_env("ENV_2"), "b") self.assertTrue(ol.get_env()["ENV_2"][1])
def test_execute(self, systemMock): """Run the execute method.""" with TemporarySessionDirectory(): self.ol.setup() self.event.execute(1) systemMock.assert_has_calls([ mock.call(['ls', '-l'], frame=1), mock.call(['ls', '-1'], frame=1), mock.call(['ls'], frame=1), ])
def test_get_session(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) # The session is only available once the outline has been "setup" # Attempting to obtain the session before setup raises an # OutlineException because the session directory does not exist. self.assertRaises(outline.OutlineException, ol.get_session) ol.setup() self.assertTrue(isinstance(ol.get_session(), outline.Session))
def test_add_layer_during_setup(self): """Test to ensure that layers added during setup are serialized.""" with TemporarySessionDirectory(): ol = outline.Outline('mr_hat') ol.add_layer(TestA('test_a')) ol.setup() ol_b = outline.load_outline( ol.get_session().get_file('outline.yaml')) # ensure the new layer was added self.assertTrue(ol_b.get_layer('test_b')) # ensure that setup was actually run on the new layer self.assertTrue(ol_b.get_layer('test_b').is_setup)
def test_get_set_arg(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) # Test normal get/set function ol.set_arg('foo', 1) self.assertEquals(1, ol.get_arg('foo')) # Test the default argument self.assertEquals('apple', ol.get_arg('foobar', 'apple')) # Test to ensure the set value is returned if a default # is passed. ol.set_arg('swoob', 8008) self.assertEquals(8008, ol.get_arg('swoob', 2112))
def test_get_set_frame_range(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) # Set frame range from string ol.set_frame_range('1-10') self.assertEquals('1-10', ol.get_frame_range()) # Set frame range from sequence ol.set_frame_range([1, 2, 3, 4, 5]) self.assertEquals('1,2,3,4,5', ol.get_frame_range()) # Set frame range from FrameSet ol.set_frame_range(FileSequence.FrameSet('5-10')) self.assertEquals('5,6,7,8,9,10', ol.get_frame_range())
def test_get_local_frame_set(self): """ Test to make sure that that the localFrameSet is being constructed properly. The local frame set is the frame list a particular frame is responsible for executing on the cue. When the chunk-size is greated then 1, the local frame set will contain more than a single frame. """ with TemporarySessionDirectory(): self.ol.setup() self.assertEqual([1, 2, 3, 4, 5], self.event.get_local_frame_set(1).getAll()) self.assertEqual([8, 9, 10], self.event.get_local_frame_set(8).getAll())
def testShortHandDepend(self): with TemporarySessionDirectory(): layer1Name = 'bah1' layer2Name = 'bah2' layer1 = Shell(layer1Name, command=['/bin/ls']) layer2 = Shell(layer2Name, command=['/bin/ls'], require=['%s:all' % layer1Name]) ol = outline.Outline(name='depend_test_v2') ol.add_layer(layer1) ol.add_layer(layer2) ol.setup() depends = ol.get_layer(layer2Name).get_depends() self.assertEqual(1, len(depends)) self.assertEqual(DependType.LayerOnLayer, depends[0].get_type()) self.assertEqual(layer1, depends[0].get_depend_on_layer())
def testAnyFrameDepend(self): with TemporarySessionDirectory(): layer1Name = 'bah1' layer2Name = 'bah2' layer1 = Shell(layer1Name, command=['/bin/ls'], range='1-2') layer2 = Shell(layer2Name, command=['/bin/ls'], range='1-1', require=['%s:any' % layer1Name]) ol = outline.Outline(name='depend_test_any_frame') ol.add_layer(layer1) ol.add_layer(layer2) ol.setup() depends = ol.get_layer(layer2Name).get_depends() self.assertEqual(1, len(depends)) self.assertEqual(DependType.FrameByFrame, depends[0].get_type()) self.assertEqual(layer1, depends[0].get_depend_on_layer())
def test_is_layer(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) self.assertTrue(ol.is_layer("cmd")) self.assertFalse(ol.is_layer("not_a_layer"))
def test_setup(self): """Test setting up the event for launch.""" with TemporarySessionDirectory(): self.event.setup()
def test_get_layers(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) self.assertEquals(1, len(ol.get_layers())) self.assertTrue(isinstance(ol.get_layers(), list))