def test_arrow_file_does_not_exist(self): with tempfile_context() as path: path.unlink() with self.assertRaisesRegex( InvalidArrowFile, "arrow-validate: .*No such file or directory"): validate_arrow_file(path)
def test_arrow_file_does_not_validate(self): array = pyarrow.StringArray.from_buffers( 1, # value_offsets: first item spans buffer offsets 0 to 1 pyarrow.py_buffer(struct.pack("II", 0, 1)), # data: a not-UTF8-safe character pyarrow.py_buffer(b"\xc9"), ) with arrow_file({"A": array}) as path: with self.assertRaisesRegex( InvalidArrowFile, "arrow-validate: --check-utf8 failed on column A"): validate_arrow_file(path)
def test_arrow_file_does_not_validate(self): array = pa.StringArray.from_buffers( 1, # value_offsets: first item spans buffer offsets 0 to 1 pa.py_buffer(struct.pack("II", 0, 1)), # data: a not-UTF8-safe character pa.py_buffer(b"\xc9"), ) table = pa.table({"A": array}) with tempfile_context() as path: with pa.ipc.RecordBatchFileWriter(path, table.schema) as writer: writer.write_table(table) with self.assertRaisesRegex(InvalidArrowFile, "arrow-validate: --check-safe failed"): validate_arrow_file(path)
def test_arrow_file_does_not_open(self): with tempfile_context() as path: path.write_bytes(b"this is not an Arrow file") with self.assertRaisesRegex(InvalidArrowFile, "arrow-validate: .*Not an Arrow file"): validate_arrow_file(path)
def test_happy_path(self): with arrow_table_context(make_column("A", ["x"])) as (path, _): validate_arrow_file(path) # do not raise
def test_happy_path(self): with arrow_file({"A": [1, 2, 3]}) as path: validate_arrow_file(path) # do not raise