Ejemplo n.º 1
0
    def testPreTasks(self):

        n1 = GafferCortex.ExecutableOpHolder()
        n2 = GafferCortex.ExecutableOpHolder()
        n2a = GafferCortex.ExecutableOpHolder()
        n2b = GafferCortex.ExecutableOpHolder()

        n1["preTasks"][0].setInput(n2["task"])
        n2["preTasks"][0].setInput(n2a["task"])

        r2 = Gaffer.Plug(name="r2")
        n2["preTasks"][1].setInput(n2b["task"])

        c = Gaffer.Context()
        self.assertEqual(n2a.preTasks(c), [])
        self.assertEqual(n2b.preTasks(c), [])
        n2PreTasks = n2.preTasks(c)
        self.assertEqual(n2PreTasks[0].node(), n2a)
        self.assertEqual(n2PreTasks[0].context(), c)
        self.assertEqual(n2PreTasks[1].node(), n2b)
        self.assertEqual(n2PreTasks[1].context(), c)
        t1 = GafferDispatch.ExecutableNode.Task(n2a, c)
        t2 = GafferDispatch.ExecutableNode.Task(n2b, c)
        self.assertEqual(n2PreTasks[0], t1)
        self.assertEqual(n2PreTasks[1], t2)
        self.assertEqual(len(set(n2.preTasks(c)).difference([t1, t2])), 0)
        self.assertEqual(n1.preTasks(c),
                         [GafferDispatch.ExecutableNode.Task(n2, c)])
Ejemplo n.º 2
0
    def testRequirements(self):

        n1 = GafferCortex.ExecutableOpHolder()
        n2 = GafferCortex.ExecutableOpHolder()
        n2a = GafferCortex.ExecutableOpHolder()
        n2b = GafferCortex.ExecutableOpHolder()

        r1 = Gaffer.Plug(name="r1")
        n1['requirements'].addChild(r1)
        r1.setInput(n2['requirement'])

        r1 = Gaffer.Plug(name="r1")
        n2['requirements'].addChild(r1)
        r1.setInput(n2a['requirement'])

        r2 = Gaffer.Plug(name="r2")
        n2['requirements'].addChild(r2)
        r2.setInput(n2b['requirement'])

        c = Gaffer.Context()
        self.assertEqual(n2a.requirements(c), [])
        self.assertEqual(n2b.requirements(c), [])
        n2Requirements = n2.requirements(c)
        self.assertEqual(n2Requirements[0].node(), n2a)
        self.assertEqual(n2Requirements[0].context(), c)
        self.assertEqual(n2Requirements[1].node(), n2b)
        self.assertEqual(n2Requirements[1].context(), c)
        t1 = Gaffer.ExecutableNode.Task(n2a, c)
        t2 = Gaffer.ExecutableNode.Task(n2b, c)
        self.assertEqual(n2Requirements[0], t1)
        self.assertEqual(n2Requirements[1], t2)
        self.assertEqual(len(set(n2.requirements(c)).difference([t1, t2])), 0)
        self.assertEqual(n1.requirements(c),
                         [Gaffer.ExecutableNode.Task(n2, c)])
Ejemplo n.º 3
0
    def testHash(self):

        c = Gaffer.Context()
        c.setFrame(1)
        c2 = Gaffer.Context()
        c2.setFrame(2)

        n = GafferCortex.ExecutableOpHolder()
        op = TestOp()

        # output doesn't vary until we set an op
        self.assertEqual(n.hash(c), IECore.MurmurHash())

        # output varies if any op is set
        n.setParameterised(op)
        self.assertNotEqual(n.hash(c), IECore.MurmurHash())

        # output doesn't vary by time unless ${frame} is used by the parameters
        self.assertEqual(n.hash(c), n.hash(c2))

        # output varies by time because ${frame} is used by the parameters
        n["parameters"]["stringParm"].setValue("${frame}")
        self.assertNotEqual(n.hash(c), n.hash(c2))

        # output varies any context entry used by the parameters
        n["parameters"]["stringParm"].setValue("${test}")
        self.assertEqual(n.hash(c), n.hash(c2))
        c["test"] = "a"
        self.assertNotEqual(n.hash(c), n.hash(c2))
        c2["test"] = "b"
        self.assertNotEqual(n.hash(c), n.hash(c2))
        c2["test"] = "a"
        self.assertEqual(n.hash(c), n.hash(c2))
Ejemplo n.º 4
0
    def testContextSubstitutions(self):

        n = GafferCortex.ExecutableOpHolder()
        op = TestOp()
        n.setParameterised(op)
        self.assertEqual(op.counter, 0)
        self.assertEqual(op.stringValue, "")

        c = Gaffer.Context()
        c.setFrame(1)
        with c:
            n.execute()
        self.assertEqual(op.counter, 1)
        self.assertEqual(op.stringValue, "")

        n["parameters"]["stringParm"].setValue("${frame}")
        with c:
            n.execute()
        self.assertEqual(op.counter, 2)
        self.assertEqual(op.stringValue, "1")

        # variable outside the context (and environment) get removed
        n["parameters"]["stringParm"].setValue("${test}")
        with c:
            n.execute()
        self.assertEqual(op.counter, 3)
        self.assertEqual(op.stringValue, "")

        c["test"] = "passed"
        with c:
            n.execute()
        self.assertEqual(op.counter, 4)
        self.assertEqual(op.stringValue, "passed")
Ejemplo n.º 5
0
    def testExecutablePlugs(self):

        n = GafferCortex.ExecutableOpHolder()
        self.assertEqual(n['requirement'].direction(),
                         Gaffer.Plug.Direction.Out)
        self.assertEqual(n['requirements'].direction(),
                         Gaffer.Plug.Direction.In)
Ejemplo n.º 6
0
    def testType(self):

        n = GafferCortex.ExecutableOpHolder()
        self.assertEqual(n.typeName(), "GafferCortex::ExecutableOpHolder")
        self.failUnless(
            n.isInstanceOf(
                GafferCortex.ParameterisedHolderExecutableNode.staticTypeId()))
        self.failUnless(n.isInstanceOf(Gaffer.Node.staticTypeId()))
Ejemplo n.º 7
0
	def testExecutableMethods( self ) :

		n = GafferCortex.ExecutableOpHolder()
		opSpec = GafferCortexTest.ParameterisedHolderTest.classSpecification( "primitive/renameVariables", "IECORE_OP_PATHS" )[:-1]
		n.setOp( *opSpec )
		c = Gaffer.Context()
		h = n.hash(c)
		self.assertEqual( n.hash(c), h )
Ejemplo n.º 8
0
    def testHash(self):

        n = GafferCortex.ExecutableOpHolder()
        opSpec = GafferCortexTest.ParameterisedHolderTest.classSpecification(
            "files/sequenceRenumber", "IECORE_OP_PATHS")[:-1]
        n.setOp(*opSpec)
        c = Gaffer.Context()
        h = n.hash(c)
        self.assertEqual(n.hash(c), h)
Ejemplo n.º 9
0
    def testExecute(self):

        n = GafferCortex.ExecutableOpHolder()
        op = TestOp()
        n.setParameterised(op)
        script = n.scriptNode()
        self.assertEqual(op.counter, 0)
        with Gaffer.Context():
            n.execute()
        self.assertEqual(op.counter, 1)
Ejemplo n.º 10
0
	def testSerialise( self ) :

		s = Gaffer.ScriptNode()
		s["n"] = GafferCortex.ExecutableOpHolder()

		opSpec = GafferCortexTest.ParameterisedHolderTest.classSpecification( "primitive/renameVariables", "IECORE_OP_PATHS" )[:-1]
		s["n"].setOp( *opSpec )

		s2 = Gaffer.ScriptNode()
		s2.execute( s.serialise() )

		self.assertEqual( s["n"]["parameters"].keys(), s2["n"]["parameters"].keys() )
Ejemplo n.º 11
0
    def testSetOp(self):

        n = GafferCortex.ExecutableOpHolder()
        opSpec = GafferCortexTest.ParameterisedHolderTest.classSpecification(
            "primitive/renameVariables", "IECORE_OP_PATHS")[:-1]
        n.setOp(*opSpec)
Ejemplo n.º 12
0
    def testExecutablePlugs(self):

        n = GafferCortex.ExecutableOpHolder()
        self.assertEqual(n["task"].direction(), Gaffer.Plug.Direction.Out)
        self.assertEqual(n["preTasks"].direction(), Gaffer.Plug.Direction.In)
Ejemplo n.º 13
0
    def testIsExecutable(self):

        self.assertTrue(
            isinstance(GafferCortex.ExecutableOpHolder(),
                       GafferDispatch.ExecutableNode))
Ejemplo n.º 14
0
    def testSetParameterised(self):

        n = GafferCortex.ExecutableOpHolder()
        op = TestOp()
        n.setParameterised(op)
        self.assertEqual(op, n.getOp())
Ejemplo n.º 15
0
    def testSetOp(self):

        n = GafferCortex.ExecutableOpHolder()
        opSpec = GafferCortexTest.ParameterisedHolderTest.classSpecification(
            "files/sequenceRenumber", "IECORE_OP_PATHS")[:-1]
        n.setOp(*opSpec)