def test_null(self): schema_null = schema.parse('"null"') avro_io.check_schema(datum=None, schema=schema_null) try: avro_io.check_schema(datum=1, schema=schema_null) self.fail("Should have failed") except schema.AvroException as exn: pass
def test_array(self): schema_array_int = schema.parse('{"type": "array", "items": "int"}') avro_io.check_schema(datum=[1], schema=schema_array_int) avro_io.check_schema(datum=[1, 2, 3], schema=schema_array_int) try: avro_io.check_schema(datum=[1, 2, 3, 1<<33], schema=schema_array_int) self.fail("Should have failed") except schema.AvroException as exn: pass try: avro_io.check_schema(datum=["bad"], schema=schema_array_int) self.fail("Should have failed") except schema.AvroException as exn: pass
def test_array(self): schema_array_int = schema.parse('{"type": "array", "items": "int"}') avro_io.check_schema(datum=[1], schema=schema_array_int) avro_io.check_schema(datum=[1, 2, 3], schema=schema_array_int) try: avro_io.check_schema(datum=[1, 2, 3, 1 << 33], schema=schema_array_int) self.fail("Should have failed") except schema.AvroException as exn: pass try: avro_io.check_schema(datum=["bad"], schema=schema_array_int) self.fail("Should have failed") except schema.AvroException as exn: pass
def test_int(self): schema_int = schema.parse('"int"') avro_io.check_schema(datum=1, schema=schema_int) try: avro_io.check_schema(datum=1 << 33, schema=schema_int) self.fail("Should have failed") except schema.AvroException as exn: pass try: avro_io.check_schema(datum="bad", schema=schema_int) self.fail("Should have failed") except schema.AvroException as exn: pass
def test_int(self): schema_int = schema.parse('"int"') avro_io.check_schema(datum=1, schema=schema_int) try: avro_io.check_schema(datum=1<<33, schema=schema_int) self.fail("Should have failed") except schema.AvroException as exn: pass try: avro_io.check_schema(datum="bad", schema=schema_int) self.fail("Should have failed") except schema.AvroException as exn: pass
def test_record(self): schema_record = schema.parse(""" { "type": "record", "name": "Test", "fields": [{"name": "f", "type": "long"}] } """) avro_io.check_schema(datum={"f": 1}, schema=schema_record) try: avro_io.check_schema(datum=[], schema=schema_record) self.fail("Should have failed") except schema.AvroException as exn: pass try: avro_io.check_schema(datum={}, schema=schema_record) self.fail("Should have failed") except schema.AvroException as exn: pass