Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 committed Sep 25, 2022
1 parent 9c7d3a1 commit a013681
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
14 changes: 4 additions & 10 deletions python/tests/pyspark_integration/test_write_to_pyspark.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@
import pytest

from deltalake import write_deltalake
from deltalake.deltalake import PyDeltaTableError
from deltalake._internal import PyDeltaTableError
from deltalake.writer import DeltaTableProtocolError

from .utils import assert_spark_read_equal, get_spark

try:
from pandas.testing import assert_frame_equal
except ModuleNotFoundError:
_has_pandas = False
else:
_has_pandas = True


try:
import delta
import delta.pip_utils
Expand Down Expand Up @@ -89,6 +82,7 @@ def test_write_invariant(tmp_path: pathlib.Path):
with pytest.raises(
PyDeltaTableError, match="Invariant \(c1 > 3\) violated by value .+2"
):
# raise PyDeltaTableError("test")
write_deltalake(str(tmp_path), invalid_data, mode="overwrite")

# Can write valid data to the table
Expand All @@ -115,7 +109,7 @@ def test_checks_min_writer_version(tmp_path: pathlib.Path):
spark.sql(f"ALTER TABLE delta.`{str(tmp_path)}` ADD CONSTRAINT x CHECK (c1 > 2)")

with pytest.raises(
PyDeltaTableError, match="This table's min_writer_version is 3, but"
DeltaTableProtocolError, match="This table's min_writer_version is 3, but"
):
valid_data = pa.table({"c1": pa.array([5, 6])})
write_deltalake(str(tmp_path), valid_data, mode="append")
2 changes: 1 addition & 1 deletion python/tests/test_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def test_writer_null_stats(tmp_path: pathlib.Path):


def test_writer_fails_on_protocol(existing_table: DeltaTable, sample_data: pa.Table):
existing_table.protocol = Mock(return_value=ProtocolVersions(1, 2))
existing_table.protocol = Mock(return_value=ProtocolVersions(1, 3))
with pytest.raises(DeltaTableProtocolError):
write_deltalake(existing_table, sample_data, mode="overwrite")

Expand Down

0 comments on commit a013681

Please sign in to comment.