def testTypeFancy(self): """Tests a config style type property.""" prop = self._makeProp(kind=config.List(int)) for value in (1, "hi", [3, "test"]): with self.assertRaises(TypeError): prop.interpret(value) self.assertEqual([2, 3], prop.interpret([2, 3]))
def test_list(self): cd = config.List((int, type(None))) self.assertEqual( cd.schema_proto(), d.Schema(list=d.Schema.List( inner_type=[d.Schema.NUMBER, d.Schema.NULL], )) )
def testTypeFancy(self): """Tests a config style type property.""" prop = make_prop(kind=config.List(int)) for value in (1, 'hi', [3, 'test']): with self.assertRaises(TypeError): prop.interpret(value, {}) self.assertEqual([2, 3], prop.interpret([2, 3], {}))
def test_config_group_schema(self): cg = config.ConfigGroupSchema( combo=config.Single((int, float), empty_val=20), other=config.List(str), field=config.Single((str, type(None))), ) self.assertEqual( cg.schema_proto(), d.Schema(struct=d.Schema.Struct(type_map={ 'combo': d.Schema(single=d.Schema.Single( inner_type=[d.Schema.NUMBER], required=True, default_json='20', )), 'other': d.Schema(list=d.Schema.List( inner_type=[d.Schema.STRING], )), 'field': d.Schema(single=d.Schema.Single( inner_type=[d.Schema.STRING, d.Schema.NULL], required=True, default_json='null', )), })))