Skip to content

Commit

Permalink
test(datasets): don't require network for examples
Browse files Browse the repository at this point in the history
Signed-off-by: Deepyaman Datta <[email protected]>
  • Loading branch information
deepyaman committed Apr 8, 2024
1 parent 9b8d2e8 commit bbec217
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions kedro-datasets/tests/ibis/test_table_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

@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)
path = (tmp_path_factory.mktemp("data") / "test.csv").as_posix()
ibis.memtable({"col1": [1, 2], "col2": [4, 5], "col3": [5, 6]}).to_csv(path)
return path


@pytest.fixture
def database(tmp_path):
return (tmp_path / "penguins.ddb").as_posix()
return (tmp_path / "file.db").as_posix()


@pytest.fixture
Expand All @@ -27,7 +27,7 @@ def connection_config(database):
@pytest.fixture
def table_dataset(connection_config, load_args, save_args):
return TableDataset(
table_name="penguins",
table_name="test",
connection=connection_config,
load_args=load_args,
save_args=save_args,
Expand Down Expand Up @@ -59,11 +59,8 @@ def test_save_and_load(self, table_dataset, dummy_table, database):

# Verify that the appropriate materialization strategy was used.
con = duckdb.connect(database)
assert not con.sql("SELECT * FROM duckdb_tables").fetchnumpy()["database_name"]
assert (
"penguins"
in con.sql("SELECT * FROM duckdb_views").fetchnumpy()["database_name"]
)
assert not con.sql("SELECT * FROM duckdb_tables").fetchnumpy()["table_name"]
assert "test" in con.sql("SELECT * FROM duckdb_views").fetchnumpy()["view_name"]

def test_exists(self, table_dataset, dummy_table):
"""Test `exists` method invocation for both existing and
Expand All @@ -85,10 +82,9 @@ def test_save_extra_params(self, table_dataset, save_args, dummy_table, database
# Verify that the appropriate materialization strategy was used.
con = duckdb.connect(database)
assert (
"penguins"
in con.sql("SELECT * FROM duckdb_tables").fetchnumpy()["database_name"]
"test" in con.sql("SELECT * FROM duckdb_tables").fetchnumpy()["table_name"]
)
assert not con.sql("SELECT * FROM duckdb_views").fetchnumpy()["database_name"]
assert not con.sql("SELECT * FROM duckdb_views").fetchnumpy()["view_name"]

def test_no_filepath_or_table_name(connection_config):
pattern = r"Must provide at least one of `filepath` or `table_name`\."
Expand Down

0 comments on commit bbec217

Please sign in to comment.