def test_ldtype_literal_list_is_list(self): x = {'prop': {'@set': [2, 3]}} result = model.ldtype('prop', x['prop']) self.assertTrue(result is model.ldset)
def test_ldtype_context_defined_list_is_list(self): x = {'prop': [1, 2]} _ctx = """ { "@context": { "prop": { "@container": "@list", "@id": "http://example.com/prop" } } } """ ctx = model.Context(_ctx) result = model.ldtype('prop', x['prop'], ctx=ctx) self.assertTrue(result is model.ldlist)
def opt_empty_collection(context): return functor.trans_values( lambda x: [], pred=lambda k, v: model.is_empty_collection(v) and (model.ldtype(k, v, context) is model.ldset or k in context.defns))
def add_singleton_sets(context): return functor.trans_values( lambda x: [x], pred=lambda k, v: model.ldtype(k, v, context) is model.ldset and not isinstance(v, list) and not isinstance(v, dict))