mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
path_info: remove dict path_info, introduce PathInfo class
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import configobj
|
||||
from dvc.path.local import LocalPathInfo
|
||||
from dvc.remote.base import RemoteBase
|
||||
from mock import patch
|
||||
|
||||
@@ -198,7 +199,7 @@ def test_dir_checksum_should_be_key_order_agnostic(dvc):
|
||||
with open(file2, "w") as fobj:
|
||||
fobj.write("2")
|
||||
|
||||
path_info = {"scheme": "local", "path": data_dir}
|
||||
path_info = LocalPathInfo(path=data_dir)
|
||||
with dvc.state:
|
||||
with patch.object(
|
||||
RemoteBase,
|
||||
|
||||
+9
-11
@@ -1,8 +1,10 @@
|
||||
import uuid
|
||||
import posixpath
|
||||
from copy import copy
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
from dvc.path.s3 import S3PathInfo
|
||||
|
||||
from dvc.remote.s3 import RemoteS3
|
||||
from tests.func.test_data_cloud import TEST_AWS_REPO_BUCKET, _should_test_aws
|
||||
@@ -10,13 +12,11 @@ from tests.func.test_data_cloud import TEST_AWS_REPO_BUCKET, _should_test_aws
|
||||
|
||||
def _get_src_dst():
|
||||
prefix = str(uuid.uuid4())
|
||||
from_info = {
|
||||
"scheme": "s3",
|
||||
"bucket": TEST_AWS_REPO_BUCKET,
|
||||
"path": posixpath.join(prefix, "from"),
|
||||
}
|
||||
to_info = from_info.copy()
|
||||
to_info["path"] = posixpath.join(prefix, "to")
|
||||
from_info = S3PathInfo(
|
||||
bucket=TEST_AWS_REPO_BUCKET, path=posixpath.join(prefix, "from")
|
||||
)
|
||||
to_info = copy(from_info)
|
||||
to_info.path = posixpath.join(prefix, "to")
|
||||
return from_info, to_info
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@ def test_copy_singlepart_preserve_etag():
|
||||
pytest.skip()
|
||||
|
||||
s3 = boto3.client("s3")
|
||||
s3.put_object(
|
||||
Bucket=from_info["bucket"], Key=from_info["path"], Body="data"
|
||||
)
|
||||
s3.put_object(Bucket=from_info.bucket, Key=from_info.path, Body="data")
|
||||
|
||||
RemoteS3._copy(s3, from_info, to_info)
|
||||
|
||||
@@ -71,5 +69,5 @@ def test_copy_multipart_preserve_etag():
|
||||
pytest.skip()
|
||||
|
||||
s3 = boto3.client("s3")
|
||||
_upload_multipart(s3, from_info["bucket"], from_info["path"])
|
||||
_upload_multipart(s3, from_info.bucket, from_info.path)
|
||||
RemoteS3._copy(s3, from_info, to_info)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import mock
|
||||
from dvc.path.local import LocalPathInfo
|
||||
|
||||
from dvc.utils.compat import str
|
||||
|
||||
@@ -14,7 +15,7 @@ from tests.basic_env import TestDvc
|
||||
class TestState(TestDvc):
|
||||
def test_update(self):
|
||||
path = os.path.join(self.dvc.root_dir, self.FOO)
|
||||
path_info = {"scheme": "local", "path": path}
|
||||
path_info = LocalPathInfo(path=path)
|
||||
md5 = file_md5(path)[0]
|
||||
|
||||
state = State(self.dvc, self.dvc.config.config)
|
||||
@@ -77,6 +78,6 @@ class TestGetStateRecordForInode(TestDvc):
|
||||
get_inode_mock.side_effect = self.mock_get_inode(path, inode)
|
||||
|
||||
with state:
|
||||
state.save({"scheme": "local", "path": path}, md5)
|
||||
state.save(LocalPathInfo(path=path), md5)
|
||||
ret = state.get_state_record_for_inode(inode)
|
||||
self.assertIsNotNone(ret)
|
||||
|
||||
Reference in New Issue
Block a user