Skip to content

Commit 13d356e

Browse files
Add some tests
1 parent f11141a commit 13d356e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

pins/tests/test_adaptors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ def test_non_df(self):
2727
assert not isinstance(adaptor, PandasAdaptor)
2828
assert not isinstance(adaptor, DFAdaptor)
2929

30+
def test_already_adaptor(self):
31+
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
32+
adaptor = create_adaptor(df)
33+
assert isinstance(adaptor, PandasAdaptor)
34+
assert create_adaptor(adaptor) is adaptor
35+
3036

3137
class TestAdaptor:
3238
def test_write_json(self, tmp_path: Path):

pins/tests/test_drivers.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pandas as pd
77
import pytest
88

9+
from pins._adaptors import create_adaptor
910
from pins.config import PINS_ENV_INSECURE_READ
1011
from pins.drivers import default_title, load_data, load_path, save_data
1112
from pins.errors import PinsInsecureReadError
@@ -163,6 +164,23 @@ def test_driver_apply_suffix_false(tmp_path: Path):
163164
assert Path(res_fname).name == "some_df"
164165

165166

167+
class TestSaveData:
168+
def test_accepts_pandas_df(self, tmp_path: Path):
169+
import pandas as pd
170+
171+
df = pd.DataFrame({"x": [1, 2, 3]})
172+
result = save_data(df, tmp_path / "some_df", "csv")
173+
assert Path(result) == tmp_path / "some_df.csv"
174+
175+
def test_accepts_adaptor(self, tmp_path: Path):
176+
import pandas as pd
177+
178+
df = pd.DataFrame({"x": [1, 2, 3]})
179+
adaptor = create_adaptor(df)
180+
result = save_data(adaptor, tmp_path / "some_df", "csv")
181+
assert Path(result) == tmp_path / "some_df.csv"
182+
183+
166184
class TestLoadFile:
167185
def test_str_file(self):
168186
class _MockMetaStrFile:

0 commit comments

Comments
 (0)