예제 #1
0
 def createParam(self, name, value="", cpp_type="string", options=[], required=False, user_added=False):
     p = ParameterInfo(None, name)
     p.value = value
     p.cpp_type = cpp_type
     p.options = options
     p.required = required
     p.user_added = user_added
     return p
예제 #2
0
 def createParam(self, name, value="", cpp_type="string", options=[], required=False, user_added=False, group="Main"):
     p = ParameterInfo(None, name)
     p.value = value
     p.cpp_type = cpp_type
     p.options = options
     p.required = required
     p.user_added = user_added
     p.group_name = group
     return p
예제 #3
0
 def createParam(self, name, value="", cpp_type="string", options=[], required=False, user_added=False, basic_type="String"):
     p = ParameterInfo(None, name)
     p.value = value
     p.cpp_type = cpp_type
     p.basic_type = basic_type
     p.options = options
     p.required = required
     p.user_added = user_added
     return p
예제 #4
0
    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")
예제 #5
0
    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")