示例#1
0
    def test_schema(self):
        schema_item = SchemaItem("TestItem")
        self.assertIsInstance(schema_item, SchemaItem)
        self.assertEqual(schema_item.iget_type(6), ContentTypeEnum.CONFIG_STRING)
        schema_item.iset_type(0, ContentTypeEnum.CONFIG_INT)
        self.assertEqual(schema_item.iget_type(0), ContentTypeEnum.CONFIG_INT)
        schema_item.set_argc_minmax(3, 6)

        del schema_item
示例#2
0
 def __getitem__(self, key):
     if key in self:
         item = self._get_item(key)
         item.setParent(self)
         return item
     else:
         if key in self._parser:
             schema_item = SchemaItem(key)
             return ContentItem(schema_item)
         else:
             raise KeyError("No such key: %s" % key)
示例#3
0
    def test_schema(self):
        schema_item = SchemaItem("TestItem")
        self.assertIsInstance(schema_item, SchemaItem)
        self.assertEqual(schema_item.iget_type(6), ContentTypeEnum.CONFIG_STRING)
        schema_item.iset_type(0, ContentTypeEnum.CONFIG_INT)
        self.assertEqual(schema_item.iget_type(0), ContentTypeEnum.CONFIG_INT)
        schema_item.set_argc_minmax(3, 6)

        self.assertTrue(SchemaItem.validString(ContentTypeEnum.CONFIG_INT, "100"))
        self.assertFalse(SchemaItem.validString(ContentTypeEnum.CONFIG_INT, "100.99"))
        self.assertTrue(SchemaItem.validString(ContentTypeEnum.CONFIG_FLOAT, "100.99"))
        self.assertFalse(SchemaItem.validString(ContentTypeEnum.CONFIG_FLOAT, "100.99X"))
        self.assertTrue(SchemaItem.validString(ContentTypeEnum.CONFIG_STRING, "100.99XX"))
        self.assertTrue(SchemaItem.validString(ContentTypeEnum.CONFIG_PATH, "100.99XX"))


        del schema_item