Esempio n. 1
0
    def testInvalidSpec(self):
        with self.assertRaises(Exception):
            _x = Spec()

        with self.assertRaises(Exception):
            _x = Spec(description=3)

        with self.assertRaises(Exception):
            _x = Spec(description="123", singleNodeOnly=3)
Esempio n. 2
0
    def testValidSpec(self):
        try:
            x = Spec(description="123", singleNodeOnly=True)
            x.invariant()

            x = Spec(description="123", singleNodeOnly=True)
            x.commands = dict(command1=CommandSpec("A command"),
                              command2=CommandSpec("Another command"))
            x.invariant()
        except:
            self.fail("Got unexpected exception")
Esempio n. 3
0
    def testSpec_toDict(self):
        x = Spec(description="123", singleNodeOnly=True)
        d = x.toDict()
        self.assertEqual(d["description"], "123")
        self.assertTrue(d["singleNodeOnly"])
        self.assertTrue(d["inputs"] == d["outputs"] == d["parameters"] ==
                        d["commands"] == {})

        x.inputs = dict(i1=InputSpec(dataType="int"),
                        i2=InputSpec(dataType="str", isDefaultInput=True))
        x.outputs = dict(o=OutputSpec(dataType="float", count=8))
        x.parameters = dict(p=ParameterSpec(description="param",
                                            dataType="float",
                                            defaultValue=3.14,
                                            accessMode="Create"))

        d = x.toDict()
        inputs = d["inputs"]
        self.assertEqual(len(inputs), 2)
        i1 = inputs["i1"]
        self.assertEqual(i1["count"], 1)
        self.assertFalse(i1["isDefaultInput"])
        self.assertEqual(i1["description"], "")
        self.assertEqual(i1["dataType"], "int")
        self.assertFalse(i1["required"])
        self.assertTrue(i1["requireSplitterMap"])
        self.assertFalse(i1["regionLevel"])

        i2 = inputs["i2"]
        self.assertEqual(i2["count"], 1)
        self.assertTrue(i2["isDefaultInput"])
        self.assertEqual(i2["description"], "")
        self.assertEqual(i2["dataType"], "str")
        self.assertFalse(i2["required"])
        self.assertTrue(i2["requireSplitterMap"])
        self.assertFalse(i2["regionLevel"])

        outputs = d["outputs"]
        self.assertEqual(len(outputs), 1)
        o = outputs["o"]
        self.assertEqual(o["count"], 8)
        self.assertFalse(o["isDefaultOutput"])
        self.assertEqual(o["description"], "")
        self.assertEqual(o["dataType"], "float")
        self.assertFalse(o["regionLevel"])

        parameters = d["parameters"]
        self.assertEqual(len(parameters), 1)
        p = parameters["p"]
        self.assertEqual(p["description"], "param")
        self.assertEqual(p["dataType"], "float")
        self.assertEqual(p["accessMode"], "Create")
        self.assertEqual(p["defaultValue"], 3.14)
        self.assertEqual(p["count"], 1)
        self.assertEqual(p["constraints"], "")

        self.assertEqual(d["commands"], {})
Esempio n. 4
0
    def testSpec_toDict(self):
        x = Spec(description="123", singleNodeOnly=True)
        d = x.toDict()
        self.assertEqual(d["description"], "123")
        self.assertTrue(d["singleNodeOnly"])
        self.assertTrue(d["inputs"] == d["outputs"] == d["parameters"] ==
                        d["commands"] == {})

        x.inputs = dict(
            i1=InputSpec(dataType="int"),
            i2=InputSpec(dataType="str", isDefaultInput=True))
        x.outputs = dict(o=OutputSpec(dataType="float", count=8))
        x.parameters = dict(
            p=ParameterSpec(
                description="param",
                dataType="float",
                defaultValue=3.14,
                accessMode="Create"))

        d = x.toDict()
        inputs = d["inputs"]
        self.assertEqual(len(inputs), 2)
        i1 = inputs["i1"]
        self.assertEqual(i1["count"], 1)
        self.assertFalse(i1["isDefaultInput"])
        self.assertEqual(i1["description"], "")
        self.assertEqual(i1["dataType"], "int")
        self.assertFalse(i1["required"])
        self.assertTrue(i1["requireSplitterMap"])
        self.assertFalse(i1["regionLevel"])

        i2 = inputs["i2"]
        self.assertEqual(i2["count"], 1)
        self.assertTrue(i2["isDefaultInput"])
        self.assertEqual(i2["description"], "")
        self.assertEqual(i2["dataType"], "str")
        self.assertFalse(i2["required"])
        self.assertTrue(i2["requireSplitterMap"])
        self.assertFalse(i2["regionLevel"])

        outputs = d["outputs"]
        self.assertEqual(len(outputs), 1)
        o = outputs["o"]
        self.assertEqual(o["count"], 8)
        self.assertFalse(o["isDefaultOutput"])
        self.assertEqual(o["description"], "")
        self.assertEqual(o["dataType"], "float")
        self.assertFalse(o["regionLevel"])

        parameters = d["parameters"]
        self.assertEqual(len(parameters), 1)
        p = parameters["p"]
        self.assertEqual(p["description"], "param")
        self.assertEqual(p["dataType"], "float")
        self.assertEqual(p["accessMode"], "Create")
        self.assertEqual(p["defaultValue"], 3.14)
        self.assertEqual(p["count"], 1)
        self.assertEqual(p["constraints"], "")

        self.assertEqual(d["commands"], {})
Esempio n. 5
0
  def testValidSpec(self):
    try:
      x = Spec(description="123", singleNodeOnly=True)
      x.invariant()

      x = Spec(description="123", singleNodeOnly=True)
      x.commands = dict(command1=CommandSpec("A command"),
                        command2=CommandSpec("Another command"))
      x.invariant()
    except:
      self.fail("Got unexpected exception")