mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
Currently we kinda assume that whatever is returned by `get_file_hash` is of type self.PARAM_CHECKSUM, which is not actually true. E.g. for http it might return `etag` or `md5`, but we don't distinguish between those and call both `etag`. This is becoming more relevant for dir hashes that are computed a few different ways (e.g. in-memory md5 or upload to remote and get etag for the dir file). Prerequisite for #4144 and #3069
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
from dvc.path_info import PathInfo
|
|
from dvc.tree.azure import AzureTree
|
|
|
|
container_name = "container-name"
|
|
connection_string = (
|
|
"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;"
|
|
"AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsu"
|
|
"Fq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;"
|
|
"BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"
|
|
)
|
|
|
|
|
|
def test_init_env_var(monkeypatch, dvc):
|
|
monkeypatch.setenv("AZURE_STORAGE_CONTAINER_NAME", container_name)
|
|
monkeypatch.setenv("AZURE_STORAGE_CONNECTION_STRING", connection_string)
|
|
|
|
config = {"url": "azure://"}
|
|
tree = AzureTree(dvc, config)
|
|
assert tree.path_info == "azure://" + container_name
|
|
assert tree._conn_str == connection_string
|
|
|
|
|
|
def test_init(dvc):
|
|
prefix = "some/prefix"
|
|
url = f"azure://{container_name}/{prefix}"
|
|
config = {"url": url, "connection_string": connection_string}
|
|
tree = AzureTree(dvc, config)
|
|
assert tree.path_info == url
|
|
assert tree._conn_str == connection_string
|
|
|
|
|
|
def test_get_file_hash(tmp_dir, azure):
|
|
tmp_dir.gen("foo", "foo")
|
|
|
|
tree = AzureTree(None, azure.config)
|
|
to_info = azure
|
|
tree.upload(PathInfo("foo"), to_info)
|
|
assert tree.exists(to_info)
|
|
_, hash_ = tree.get_file_hash(to_info)
|
|
assert hash_
|
|
assert isinstance(hash_, str)
|
|
assert hash_.strip("'").strip('"') == hash_
|