Skip to content

Commit

Permalink
Minor fixes for tests (#312)
Browse files Browse the repository at this point in the history
* tests: cleanup azure tests
* tests: fix error with s3 fixture with global moto install
* tests: support gcs tests without internet connection
  Specify token storage argument to avoid timeouts due to credential refresh without internet connectivity.
  • Loading branch information
ap-- authored Nov 20, 2024
1 parent 635fa20 commit 6fe13a1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
4 changes: 2 additions & 2 deletions upath/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def s3_server():
port = 5555
endpoint_uri = f"http://127.0.0.1:{port}/"
proc = subprocess.Popen(
shlex.split(f"moto_server -p {port}"),
[sys.executable, *shlex.split(f"-m moto.server -p {port}")],
stderr=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
)
Expand Down Expand Up @@ -231,7 +231,7 @@ def docker_gcs():
@pytest.fixture
def gcs_fixture(docker_gcs, local_testdir):
pytest.importorskip("gcsfs")
gcs = fsspec.filesystem("gcs", endpoint_url=docker_gcs)
gcs = fsspec.filesystem("gcs", endpoint_url=docker_gcs, token="anon")
bucket_name = "test_bucket"
if gcs.exists(bucket_name):
for dir, _, keys in gcs.walk(bucket_name):
Expand Down
7 changes: 0 additions & 7 deletions upath/tests/implementations/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,6 @@ def test_rmdir(self):
with pytest.raises(NotADirectoryError):
(self.path / "a" / "file.txt").rmdir()

@pytest.mark.skip
def test_makedirs_exist_ok_false(self):
pass

def test_rglob(self, pathlib_base):
return super().test_rglob(pathlib_base)

def test_protocol(self):
# test all valid protocols for azure...
protocol = self.path.protocol
Expand Down
6 changes: 3 additions & 3 deletions upath/tests/implementations/test_gcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class TestGCSPath(BaseTests):
@pytest.fixture(autouse=True, scope="function")
def path(self, gcs_fixture):
path, endpoint_url = gcs_fixture
self.path = UPath(path, endpoint_url=endpoint_url)
self.endpoint_url = endpoint_url
self.path = UPath(path, endpoint_url=endpoint_url, token="anon")

def test_is_GCSPath(self):
assert isinstance(self.path, GCSPath)
Expand All @@ -39,7 +38,7 @@ def test_makedirs_exist_ok_false(self):

@skip_on_windows
def test_mkdir_in_empty_bucket(docker_gcs):
fs = fsspec.filesystem("gcs", endpoint_url=docker_gcs)
fs = fsspec.filesystem("gcs", endpoint_url=docker_gcs, token="anon")
fs.mkdir("my-fresh-bucket")
assert "my-fresh-bucket/" in fs.buckets
fs.invalidate_cache()
Expand All @@ -48,4 +47,5 @@ def test_mkdir_in_empty_bucket(docker_gcs):
UPath(
"gs://my-fresh-bucket/some-dir/another-dir/file",
endpoint_url=docker_gcs,
token="anon",
).parent.mkdir(parents=True, exist_ok=True)

0 comments on commit 6fe13a1

Please sign in to comment.