def testLocationNoSlashSceneInvalid(self): from random import Random from datetime import datetime r = Random(datetime.now()) name1 = randomName(r, 5, 10) name2 = randomName(r, 5, 10) eq = GafferScene.ExistenceQuery() eq["location"].setValue("") self.assertFalse(eq["exists"].getValue()) self.assertEqual(eq["closestAncestor"].getValue(), "") eq["location"].setValue(name1) self.assertFalse(eq["exists"].getValue()) self.assertEqual(eq["closestAncestor"].getValue(), "/") eq["location"].setValue(name1 + "/" + name2) self.assertFalse(eq["exists"].getValue()) self.assertEqual(eq["closestAncestor"].getValue(), "/")
def testLocationSlashPartial(self): from random import Random from datetime import datetime r = Random(datetime.now()) name1 = randomName(r, 5, 10) name2 = randomName(r, 5, 10) name3 = randomName(r, 2, 4) s = GafferScene.Sphere() s["name"].setValue(name2) g = GafferScene.Group() g["name"].setValue(name1) g["in"][0].setInput(s["out"]) eq = GafferScene.ExistenceQuery() eq["scene"].setInput(g["out"]) eq["location"].setValue("/" + name1 + "/" + name3) self.assertFalse(eq["exists"].getValue()) self.assertEqual(eq["closestAncestor"].getValue(), "/" + name1) eq["location"].setValue("/" + name1 + "/" + name2 + "/" + name3) self.assertFalse(eq["exists"].getValue()) self.assertEqual(eq["closestAncestor"].getValue(), "/" + name1 + "/" + name2)
def testEmptyLocationThenMissingLocation(self): p = GafferScene.Plane() q = GafferScene.ExistenceQuery() q["scene"].setInput(p["out"]) self.assertEqual(q["closestAncestor"].getValue(), "") q["location"].setValue("/iDontExist") self.assertEqual(q["closestAncestor"].getValue(), "/")
def testLocationSlashSceneValid(self): s = GafferScene.Sphere() eq = GafferScene.ExistenceQuery() eq["scene"].setInput(s["out"]) eq["location"].setValue("/") self.assertTrue(eq["exists"].getValue()) self.assertEqual(eq["closestAncestor"].getValue(), "/")
def testDefault(self): eq = GafferScene.ExistenceQuery() self.assertTrue(eq["exists"].getValue() == False) self.assertTrue(eq["closestAncestor"].getValue() == "")