

def testNonNodeMetadata(self):
    cs = GafferTest.CapturingSlot(Gaffer.Metadata.valueChangedSignal())
    self.assertEqual(len(cs), 0)
    Gaffer.Metadata.registerValue('testTarget', 'testInt', 1)
    self.assertEqual(Gaffer.Metadata.value('testTarget', 'testInt'), 1)
    self.assertEqual(len(cs), 1)
    self.assertEqual(cs[0], ('testTarget', 'testInt'))
    intVectorData = IECore.IntVectorData([1, 2])
    Gaffer.Metadata.registerValue('testTarget', 'testIntVectorData', intVectorData)
    self.assertEqual(Gaffer.Metadata.value('testTarget', 'testIntVectorData'), intVectorData)
    self.assertFalse(Gaffer.Metadata.value('testTarget', 'testIntVectorData').isSame(intVectorData))
    self.assertEqual(len(cs), 2)
    self.assertEqual(cs[1], ('testTarget', 'testIntVectorData'))
    Gaffer.Metadata.registerValue('testTarget', 'testDynamicValue', (lambda : 20))
    self.assertEqual(Gaffer.Metadata.value('testTarget', 'testDynamicValue'), 20)
    self.assertEqual(len(cs), 3)
    self.assertEqual(cs[2], ('testTarget', 'testDynamicValue'))
    names = Gaffer.Metadata.registeredValues('testTarget')
    self.assertTrue(('testInt' in names))
    self.assertTrue(('testIntVectorData' in names))
    self.assertTrue(('testDynamicValue' in names))
    self.assertTrue((names.index('testInt') < names.index('testIntVectorData')))
    self.assertTrue((names.index('testIntVectorData') < names.index('testDynamicValue')))

dataset/ETHPy150Open ImageEngine/gaffer/python/GafferTest/MetadataTest.py MetadataTest.testNonNodeMetadata/original