code: 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"], {})
  
file_path: nupic-legacy/tests/unit/nupic/regions/regions_spec_test.py
imports: import unittest2
  from nupic.regions.spec import Spec, InputSpec, OutputSpec, ParameterSpec, CommandSpec
label_desc: Use image node_id 11 for calling the KNNAnomalyClassifierRegionTest obj's underlying member method code with example usage: obj.testSpec_toDict() without return types