Skip to content

Commit

Permalink
✅ Added missing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafalz13 committed Jul 11, 2024
1 parent 9dcf387 commit 9602097
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/unit/test_sharepoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import pandas as pd
import pytest
import sharepy
from viadot.exceptions import CredentialError
from viadot.sources import Sharepoint
from viadot.sources.sharepoint import SharepointCredentials

DUMMY_CREDS = {"site": "test", "username": "test2", "password": "test"}
SAMPLE_DF = pd.DataFrame(
Expand All @@ -30,6 +32,27 @@ def sharepoint_mock():
return SharepointMock(credentials=DUMMY_CREDS)


def test_valid_credentials():
credentials = {
"site": "tenant.sharepoint.com",
"username": "[email protected]",
"password": "password",
}
shrp_creds = SharepointCredentials(**credentials)
assert shrp_creds.site == credentials["site"]
assert shrp_creds.username == credentials["username"]
assert shrp_creds.password == credentials["password"]


def test_missing_username():
credentials = {"site": "example.sharepoint.com", "password": "password"}
with pytest.raises(
CredentialError,
match="'site', 'username', and 'password' credentials are required.",
):
SharepointCredentials(**credentials)


def test_sharepoint_default_na(sharepoint_mock):
df = sharepoint_mock.to_df(
url="test/file.xlsx", na_values=Sharepoint.DEFAULT_NA_VALUES
Expand Down Expand Up @@ -90,3 +113,8 @@ def test__parse_excel_string_dtypes(sharepoint_mock):

for column in result_df.columns:
assert result_df[column].dtype == object


def test__load_and_parse_not_valid_extension(sharepoint_mock):
with pytest.raises(ValueError):
sharepoint_mock._load_and_parse(file_url="https://example.com/file.txt")

0 comments on commit 9602097

Please sign in to comment.