-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Read csv and parquet with polars * Add example of how to ovveride service url and token * Revert to reading csv with pandas and fix tests * Fix typing issue for PARQUET enum * Map filetypes to their corresponding reader functions
- Loading branch information
Showing
5 changed files
with
53 additions
and
16 deletions.
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
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
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
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
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 |
---|---|---|
@@ -1,21 +1,31 @@ | ||
import pandas as pd | ||
import polars as pl | ||
import pytest | ||
|
||
from dapla_pseudo.v1.supported_file_format import SupportedFileFormat | ||
from dapla_pseudo.v1.supported_file_format import read_to_df | ||
|
||
|
||
PKG = "dapla_pseudo.v1.supported_file_format" | ||
|
||
|
||
@pytest.mark.parametrize("file_format", ["json", "csv", "xml", "parquet"]) | ||
def test_get_pandas_function_name(file_format: str) -> None: | ||
# Checks that a pandas function exists for all supported file formats. | ||
supported_file_format = SupportedFileFormat(file_format) | ||
assert getattr(pd, supported_file_format.get_pandas_function_name()) | ||
TEST_FILE_PATH = "tests/v1/test_files" | ||
|
||
|
||
def test_get_pandas_function_name_unsupported_format() -> None: | ||
# Checks that a unsupported file extension raise a value error. | ||
unsupported_format = "notsupported" | ||
with pytest.raises(ValueError): | ||
SupportedFileFormat(unsupported_format) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"file_format, read_with_polars", | ||
[ | ||
("json", False), | ||
("csv", False), | ||
("xml", False), | ||
("parquet", True), | ||
], | ||
) | ||
def test_supported_files_read_with_polars(file_format: str, read_with_polars: bool) -> None: | ||
supported_file_format = SupportedFileFormat(file_format) | ||
df = read_to_df(supported_file_format, f"{TEST_FILE_PATH}/test.{file_format}") | ||
assert isinstance(df, pl.DataFrame) is read_with_polars |