Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions tests/unit/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,9 @@ def test_snow_type_to_dtype_str():
{"name": "col2", "type": "float"},
],
},
),
)
if is_pandas_available
else (None, None, None, None, None),
(
PandasDataFrameType(
[ArrayType(ArrayType(IntegerType())), IntegerType(), FloatType()]
Expand All @@ -1262,24 +1264,32 @@ def test_snow_type_to_dtype_str():
{"name": "", "type": "float"},
],
},
),
)
if is_pandas_available
else (None, None, None, None, None),
(
PandasSeriesType(IntegerType()),
"pandas_series<int>",
'{"element_type":"integer","type":"pandas_series"}',
"pandas_series",
{"type": "pandas_series", "element_type": "integer"},
),
)
if is_pandas_available
else (None, None, None, None, None),
(
PandasSeriesType(None),
"pandas_series<>",
'{"element_type":null,"type":"pandas_series"}',
"pandas_series",
{"type": "pandas_series", "element_type": None},
),
)
if is_pandas_available
else (None, None, None, None, None),
],
)
def test_datatype(tpe, simple_string, json, type_name, json_value):
if tpe is None:
pytest.skip("skip because pandas is not available")
assert tpe.simple_string() == simple_string
assert tpe.json_value() == json_value
assert tpe.json() == json
Expand Down Expand Up @@ -1371,18 +1381,28 @@ def test_datatype(tpe, simple_string, json, type_name, json_value):
PandasDataFrameType(
[StringType(), IntegerType(), FloatType()], ["id", "col1", "col2"]
),
),
)
if is_pandas_available
else (None, None),
(
PandasDataFrameType,
PandasDataFrameType(
[ArrayType(ArrayType(IntegerType())), IntegerType(), FloatType()]
),
),
(PandasSeriesType, PandasSeriesType(IntegerType())),
(PandasSeriesType, PandasSeriesType(None)),
)
if is_pandas_available
else (None, None),
(PandasSeriesType, PandasSeriesType(IntegerType()))
if is_pandas_available
else (None, None),
(PandasSeriesType, PandasSeriesType(None))
if is_pandas_available
else (None, None),
],
)
def test_structtype_from_json(datatype, tpe):
if datatype is None:
pytest.skip("skip because pandas is not available")
json_dict = tpe.json_value()
new_obj = datatype.from_json(json_dict)
assert new_obj == tpe
Expand Down
Loading