-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sharepoint handle null values (#931)
* ✨ Added `na_values` list * ✨ Modified way of casting to string to keep the NaN values * 🐛 Replaced `df` with `df_clean` * ✨ Added `DEFAULT_NA_VALUES` attribute and `_download_excel` function * 🐛 Changed pytestArgs from `src` to `tests` * ✅ Added tests for sharepoint na_values parameter * ✅ Changed parameter names in sharepoint tests * ⚡️ Assigned DEFAULT_NA_VALUES * 📝 Updated docstring * 👷 Update coverage settings --------- Co-authored-by: trymzet <[email protected]>
- Loading branch information
Showing
7 changed files
with
101 additions
and
53 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
Binary file not shown.
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,31 @@ | ||
from pathlib import Path | ||
|
||
import pandas as pd | ||
from viadot.sources import Sharepoint | ||
|
||
|
||
class SharepointMock(Sharepoint): | ||
def _download_excel(self, url=None): | ||
return pd.ExcelFile(Path("tests/unit/test_file.xlsx")) | ||
|
||
|
||
def test_sharepoint_default_na(): | ||
dummy_creds = {"site": "test", "username": "test2", "password": "test"} | ||
|
||
s = SharepointMock(credentials=dummy_creds) | ||
df = s.to_df(url="test", na_values=Sharepoint.DEFAULT_NA_VALUES) | ||
|
||
assert not df.empty | ||
assert "NA" not in list(df["col_a"]) | ||
|
||
|
||
def test_sharepoint_custom_na(): | ||
dummy_creds = {"site": "test", "username": "test", "password": "test"} | ||
|
||
s = SharepointMock(credentials=dummy_creds) | ||
df = s.to_df( | ||
url="test", na_values=[v for v in Sharepoint.DEFAULT_NA_VALUES if v != "NA"] | ||
) | ||
|
||
assert not df.empty | ||
assert "NA" in list(df["col_a"]) |