-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(datasets): implement save and reload for Ibis
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import ibis | ||
import pytest | ||
from pandas.testing import assert_frame_equal | ||
|
||
from kedro_datasets.ibis import TableDataset | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def filepath_csv(tmp_path_factory): | ||
path = (tmp_path_factory.mktemp("data") / "penguins.csv").as_posix() | ||
ibis.examples.penguins.fetch().to_csv(path) | ||
return path | ||
|
||
|
||
@pytest.fixture | ||
def connection_config(tmp_path): | ||
return {"backend": "duckdb", "database": (tmp_path / "penguins.ddb").as_posix()} | ||
|
||
|
||
@pytest.fixture | ||
def table_dataset(connection_config): | ||
return TableDataset(table_name="penguins", connection=connection_config) | ||
|
||
|
||
@pytest.fixture | ||
def dummy_table(filepath_csv, connection_config): | ||
return TableDataset( | ||
filepath=filepath_csv, file_format="csv", connection=connection_config | ||
).load() | ||
|
||
|
||
class TestTableDataset: | ||
def test_save_and_load(self, table_dataset, dummy_table): | ||
"""Test saving and reloading the data set.""" | ||
table_dataset.save(dummy_table) | ||
reloaded = table_dataset.load() | ||
assert_frame_equal(dummy_table.execute(), reloaded.execute()) |