

def testReload(self):
    s = Gaffer.ScriptNode()
    s['n1'] = GafferTest.AddNode()
    s['n2'] = GafferTest.AddNode()
    s['n3'] = GafferTest.AddNode()
    s['n2']['op1'].setInput(s['n1']['sum'])
    s['n3']['op1'].setInput(s['n2']['sum'])
    b = Gaffer.Box.create(s, Gaffer.StandardSet([s['n2']]))
    b.promotePlug(b['n2']['op2'])
    b.exportForReference('/tmp/test.grf')
    s2 = Gaffer.ScriptNode()
    s2['n1'] = GafferTest.AddNode()
    s2['n3'] = GafferTest.AddNode()
    s2['r'] = Gaffer.Reference()
    s2['r'].load('/tmp/test.grf')
    s2['r']['op1'].setInput(s2['n1']['sum'])
    s2['r']['op2'].setValue(1001)
    s2['n3']['op1'].setInput(s2['r']['sum'])
    self.assertTrue(('n2' in s2['r']))
    self.assertTrue(s2['r']['n2']['op1'].getInput().isSame(s2['r']['op1']))
    self.assertTrue(s2['r']['n2']['op2'].getInput().isSame(s2['r']['op2']))
    self.assertEqual(s2['r']['op2'].getValue(), 1001)
    self.assertTrue(s2['r']['sum'].getInput().isSame(s2['r']['n2']['sum']))
    self.assertTrue(s2['r']['op1'].getInput().isSame(s2['n1']['sum']))
    self.assertTrue(s2['n3']['op1'].getInput().isSame(s2['r']['sum']))
    originalReferencedNames = s2['r'].keys()
    b['anotherNode'] = GafferTest.AddNode()
    b.promotePlug(b['anotherNode']['op2'])
    s.serialiseToFile('/tmp/test.grf', b)
    s2['r'].load('/tmp/test.grf')
    self.assertTrue(('n2' in s2['r']))
    self.assertEqual(set(s2['r'].keys()), set((originalReferencedNames + ['anotherNode', 'op3'])))
    self.assertTrue(s2['r']['n2']['op1'].getInput().isSame(s2['r']['op1']))
    self.assertTrue(s2['r']['n2']['op2'].getInput().isSame(s2['r']['op2']))
    self.assertEqual(s2['r']['op2'].getValue(), 1001)
    self.assertTrue(s2['r']['anotherNode']['op2'].getInput().isSame(s2['r']['op3']))
    self.assertTrue(s2['r']['sum'].getInput().isSame(s2['r']['n2']['sum']))
    self.assertTrue(s2['r']['op1'].getInput().isSame(s2['n1']['sum']))
    self.assertTrue(s2['n3']['op1'].getInput().isSame(s2['r']['sum']))

dataset/ETHPy150Open ImageEngine/gaffer/python/GafferTest/ReferenceTest.py ReferenceTest.testReload/original