Skip to content

Commit

Permalink
uses Python's unittest.mock to patch the Google auth credentials check
Browse files Browse the repository at this point in the history
  • Loading branch information
RupinderKaurSSB committed Dec 11, 2024
1 parent 3ca68d4 commit 36a8aa3
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions tests/test_gcs.py
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

0 comments on commit 36a8aa3

Please sign in to comment.