Exemplo n.º 1
0
 def test_nested_record(self):
   eq_(
     _SchemaInferrer().infer({'foo': {'bax': 2}, 'bar': {'baz': 3}}),
     {
       'type': 'record',
       'name': '__Record1',
       'fields': [
         {
           'type': {
             'type': 'record',
             'name': '__Record2',
             'fields': [{'type': 'int', 'name': 'baz'}]
           },
           'name': 'bar',
         },
         {
           'type': {
             'type': 'record',
             'name': '__Record3',
             'fields': [{'type': 'int', 'name': 'bax'}]
           },
           'name': 'foo',
         },
       ]
     }
   )
Exemplo n.º 2
0
 def test_flat_record(self):
   eq_(
     _SchemaInferrer().infer({'foo': 1, 'bar': 'hello'}),
     {
       'type': 'record',
       'name': '__Record1',
       'fields': [
         {'type': 'string', 'name': 'bar'},
         {'type': 'int', 'name': 'foo'},
       ]
     }
   )
Exemplo n.º 3
0
 def test_array(self):
   eq_(
     _SchemaInferrer().infer({'foo': 1, 'bar': ['hello']}),
     {
       'type': 'record',
       'name': '__Record1',
       'fields': [
         {'type': {'type': 'array', 'items': 'string'}, 'name': 'bar'},
         {'type': 'int', 'name': 'foo'},
       ]
     }
   )