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 test_utils.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_get_path(self): """Test that the layer session path is correct.""" with test_utils.TemporarySessionDirectory(): self.assertRaises(outline.OutlineException, self.layer.get_path) self.ol.setup() expectedPath = '%s/layers/%s' % (self.ol.get_session().get_path(), self.layer.get_name()) self.assertEquals(expectedPath, self.layer.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 test_utils.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 test_utils.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_args_override(self): with test_utils.TemporarySessionDirectory(): self.ol.setup() self.layer.put_data('args_override', {'arg_to_be_overridden': 'blah.blah'}) self.layer.setup_args_override() self.assertEqual('blah.blah', self.layer.get_arg('arg_to_be_overridden'))
def test_execute(self, systemMock): """Run the execute method.""" with test_utils.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_set_name(self): newLayerName = 'arbitrary-new-name' self.layer.set_name(newLayerName) self.assertEqual(newLayerName, self.layer.get_name()) with test_utils.TemporarySessionDirectory(): self.ol.setup() self.assertRaises(outline.layer.LayerException, self.layer.set_name, 'this-should-fail')
def test_add_layer_during_setup(self): """Test to ensure that layers added during setup are serialized.""" with test_utils.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_execute(self, systemMock): """Test execution of a frame.""" os.environ = {} with test_utils.TemporarySessionDirectory(): self.ol.setup() self.layer.execute(1) systemMock.assert_has_calls([mock.call(['ps', 'aux'], frame=1)]) self.assertTrue('foo', os.environ['cue_test_01']) self.assertTrue('bar', os.environ['cue_test_02']) self.assertTrue('layer-env-a', os.environ['cue_layer_01']) self.assertTrue('layer-env-b', os.environ['cue_layer_02'])
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 test_utils.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 test_utils.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 test_utils.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_setup(self): """Test setting up the event for launch.""" with test_utils.TemporarySessionDirectory(): self.layer.setup()