forked from fsspec/universal_pathlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_azure.py
More file actions
40 lines (32 loc) · 1.17 KB
/
test_azure.py
File metadata and controls
40 lines (32 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest
from upath import UPath
from upath.errors import NotDirectoryError
from upath.implementations.cloud import AzurePath
from ..cases import BaseTests
from ..utils import skip_on_windows
@skip_on_windows
@pytest.mark.usefixtures("path")
class TestAzurePath(BaseTests):
SUPPORTS_EMPTY_DIRS = False
@pytest.fixture(autouse=True, scope="function")
def path(self, azurite_credentials, azure_fixture):
account_name, connection_string = azurite_credentials
self.storage_options = {
"account_name": account_name,
"connection_string": connection_string,
}
self.path = UPath(azure_fixture, **self.storage_options)
self.prepare_file_system()
def test_is_AzurePath(self):
assert isinstance(self.path, AzurePath)
def test_rmdir(self):
new_dir = self.path / "new_dir_rmdir"
new_dir.mkdir()
path = new_dir / "test.txt"
path.write_text("hello")
assert path.exists()
new_dir.fs.invalidate_cache()
new_dir.rmdir()
assert not new_dir.exists()
with pytest.raises(NotDirectoryError):
(self.path / "a" / "file.txt").rmdir()