def test_recorddef_type_invalid(): rdef = RecordDef([ { 'name': 'col0', 'type': 'SUPER_TYPE' }, ])
def test_recorddef_unsupported_key(): rdef = RecordDef([ { 'name': 'col0', 'xyz' : 'yeah', }, ])
def test_record_mismatch_type(): rdef = RecordDef([ {'name': 'col0', 'type': 'INT', }, ]) rec = Record( rdef, 'not convertible to INT', )
def test_record_mismatch_length(): rdef = RecordDef([ {'name': 'col0', 'type': 'STRING', }, ]) rec = Record( rdef, 'Hello', 'World' )
def test_recorddef_usage(): """Shows how to use RecordDef class.""" rdef = RecordDef([ {'name': 'col0', 'type': 'STRING', }, {'name': 'col1', }, ]) eq_(len(rdef), 2) eq_(rdef[0].name, 'col0') eq_(rdef[0].type, Type('STRING'))
def test_record_non_basic_type(): class C: pass c = C # c has too complex type as stream record rdef = RecordDef([ {'name': 'col0', }, ]) rec = Record( rdef, c, )
def test_record_usage(): """Shows how to use Record class.""" rdef = RecordDef([ {'name': 'col0', 'type': 'STRING', }, {'name': 'col1', # any basic type is allowed }, ]) rec = Record( rdef, 'Hello', 'World' ) eq_(len(rec), 2) rec = Record( rdef, 'Hello', 777 ) eq_(len(rec), 2)
def test_recorddef_name_invalid(): rdef = RecordDef([ { 'name': 'invalid-col', }, ])
def test_recorddef_required_key_lacks(): rdef = RecordDef([ { }, # at least 'name' is required ])