def testUserParams(self): b = BlockInfo(None, "/Foo", False, "") p = ParameterInfo(None, "p") p.user_added = False b.addParameter(p) b.addUserParam("bar", "val") b.addUserParam("bar", "val") p = b.getParamInfo("bar") self.assertEqual(p.user_added, True) self.assertEqual(b.paramValue("bar"), "val") b.setParamValue("bar", "val1") self.assertEqual(b.paramValue("bar"), "val1") b.removeUserParam("bar1") self.assertEqual(b.paramValue("bar"), "val1") b.removeUserParam("p") self.assertEqual(b.paramValue("p"), "") b.removeUserParam("bar") self.assertEqual(b.paramValue("bar"), None) self.assertNotIn("bar", b.parameters_list) self.assertNotIn("bar", b.parameters) b.addUserParam("bar", "val") b.addUserParam("foo", "val1") self.assertEqual(len(b.parameters_list), 3) self.assertEqual(b.parameters_list.index("bar"), 1) self.assertEqual(b.parameters_list.index("foo"), 2) b.moveUserParam("foo", 0) self.assertEqual(b.parameters_list.index("bar"), 2) self.assertEqual(b.parameters_list.index("foo"), 0) b.renameUserParam("bar1", "bar2") b.renameUserParam("p", "bar2") self.assertEqual(b.paramValue("bar2"), None) b.renameUserParam("bar", "bar1") self.assertEqual(b.paramValue("bar"), None) self.assertEqual(b.paramValue("bar1"), "val")
def testUserParams(self): b = BlockInfo(None, "/Foo", False, "") p = ParameterInfo(None, "p") p.user_added = False b.addParameter(p) b.addUserParam("bar", "val") b.addUserParam("bar", "val") p = b.getParamInfo("bar") self.assertEqual(p.user_added, True) self.assertEqual(b.paramValue("bar"), "val") b.setParamValue("bar", "val1") self.assertEqual(b.paramValue("bar"), "val1") b.removeUserParam("bar1") self.assertEqual(b.paramValue("bar"), "val1") b.removeUserParam("p") self.assertEqual(b.paramValue("p"), "") b.removeUserParam("bar") self.assertEqual(b.paramValue("bar"), None) self.assertNotIn("bar", b.parameters_list) self.assertNotIn("bar", b.parameters) b.addUserParam("bar", "val") b.addUserParam("foo", "val1") self.assertEqual(len(b.parameters_list), 3) self.assertEqual(b.parameters_list.index("bar"), 1) self.assertEqual(b.parameters_list.index("foo"), 2) b.moveUserParam("foo", 0) self.assertEqual(b.parameters_list.index("bar"), 2) self.assertEqual(b.parameters_list.index("foo"), 0) b.renameUserParam("bar1", "bar2") b.renameUserParam("p", "bar2") self.assertEqual(b.paramValue("bar2"), None) b.renameUserParam("bar", "bar1") self.assertEqual(b.paramValue("bar"), None) self.assertEqual(b.paramValue("bar1"), "val")
def testTypes(self): b = BlockInfo(None, "/Foo", False, "") self.assertEqual(b.paramValue("type"), None) b.setBlockType("t") # shouldn't do anything p = ParameterInfo(None, "type") b.addParameter(p) self.assertEqual(p.parent, b) self.assertEqual(b.paramValue("type"), "") b.setBlockType("t") # shouldn't do anything self.assertEqual(b.paramValue("type"), "t") b1 = BlockInfo(None, "/Foo/t", False, "") p = ParameterInfo(None, "p") b1.addParameter(p) b.types[b1.name] = b1 self.assertEqual(b.paramValue("p"), "") b.setParamValue("p", "val") self.assertEqual(b.paramValue("p"), "val") b.setBlockType("t1") self.assertEqual(b.paramValue("p"), None)
def testTypes(self): b = BlockInfo(None, "/Foo", False, "") self.assertEqual(b.paramValue("type"), None) b.setBlockType("t") # shouldn't do anything p = ParameterInfo(None, "type") b.addParameter(p) self.assertEqual(p.parent, b) self.assertEqual(b.paramValue("type"), "") b.setBlockType("t") # shouldn't do anything self.assertEqual(b.paramValue("type"), "t") b1 = BlockInfo(None, "/Foo/t", False, "") p = ParameterInfo(None, "p") b1.addParameter(p) b.types[b1.name] = b1 self.assertEqual(b.paramValue("p"), "") b.setParamValue("p", "val") self.assertEqual(b.paramValue("p"), "val") b.setBlockType("t1") self.assertEqual(b.paramValue("p"), None)