-
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.
uses Python's unittest.mock to patch the Google auth credentials check
- Loading branch information
1 parent
3ca68d4
commit 36a8aa3
Showing
1 changed file
with
32 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,37 @@ | ||
import os | ||
from unittest.mock import patch | ||
|
||
from dapla.gcs import GCSFileSystem | ||
|
||
|
||
def test_instance() -> None: | ||
# Chack that instantiation works with the current version of pyarrow | ||
@patch('google.auth.default', return_value=(None, None)) | ||
def test_instance(mock_auth) -> None: | ||
client = GCSFileSystem() | ||
assert client is not None | ||
|
||
|
||
@patch('google.auth.default', return_value=(None, None)) | ||
def test_init_with_dapla_lab(mock_auth) -> None: | ||
os.environ["DAPLA_REGION"] = "dapla-lab" | ||
client = GCSFileSystem(project="test-project") | ||
assert client is not None | ||
|
||
|
||
@patch('google.auth.default', return_value=(None, None)) | ||
def test_init_with_cloud_run(mock_auth) -> None: | ||
os.environ["DAPLA_REGION"] = "cloud-run" | ||
client = GCSFileSystem(project="test-project") | ||
assert client is not None | ||
|
||
|
||
@patch('google.auth.default', return_value=(None, None)) | ||
def test_init_with_custom_region(mock_auth) -> None: | ||
os.environ["DAPLA_REGION"] = "custom-region" | ||
client = GCSFileSystem(project="test-project") | ||
assert client is not None | ||
|
||
|
||
@patch('google.auth.default', return_value=(None, None)) | ||
def test_init_with_additional_kwargs(mock_auth) -> None: | ||
client = GCSFileSystem(project="test-project", timeout=100) | ||
assert client is not None |