Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: merge local related function in Local helper class #3134

Merged
merged 1 commit into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
GCP,
GDrive,
HDFS,
Local,
S3,
SSHMocked,
OSS,
Expand All @@ -44,7 +45,6 @@
TEST_GDRIVE_CLIENT_ID,
TEST_GDRIVE_CLIENT_SECRET,
TEST_REMOTE,
get_local_url,
)


Expand Down Expand Up @@ -278,10 +278,10 @@ def _get_cloud_class(self):

class TestRemoteLOCAL(TestDataCloudBase):
def _should_test(self):
return True
return Local.should_test()

def _get_url(self):
self.dname = get_local_url()
self.dname = Local.get_url()
return self.dname

def _get_cloud_class(self):
Expand Down Expand Up @@ -420,7 +420,7 @@ def test(self):

class TestRemoteLOCALCLI(TestDataCloudCLIBase):
def _test(self):
url = get_local_url()
url = Local.get_url()

self.main(["remote", "add", TEST_REMOTE, url])

Expand Down Expand Up @@ -545,7 +545,7 @@ def main(self, args):
self.assertEqual(ret, 0)

def _test(self):
url = get_local_url()
url = Local.get_url()
self.main(["remote", "add", "-d", TEST_REMOTE, url])

stage = self.dvc.run(outs=["bar"], cmd="echo bar > bar")
Expand Down Expand Up @@ -577,11 +577,11 @@ def main(self, args):
self.assertEqual(ret, 0)

def _get_url(self):
self.dname = get_local_url()
self.dname = Local.get_url()
return self.dname

def _should_test(self):
return True
return Local.should_test()

def _get_cloud_class(self):
return RemoteLOCAL
Expand Down Expand Up @@ -659,7 +659,7 @@ def test(self):
with patch.object(
RemoteLOCAL, "get_file_checksum", test_get_file_checksum
):
url = get_local_url()
url = Local.get_url()
ret = main(["remote", "add", "-d", TEST_REMOTE, url])
self.assertEqual(ret, 0)
ret = main(["config", "cache.type", "hardlink"])
Expand Down
4 changes: 2 additions & 2 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dvc.remote.base import RemoteBASE
from dvc.compat import fspath
from tests.basic_env import TestDvc
from tests.remotes import get_local_storagepath
from tests.remotes import Local


class TestRemote(TestDvc):
Expand Down Expand Up @@ -159,7 +159,7 @@ class TestRemoteShouldHandleUppercaseRemoteName(TestDvc):
upper_case_remote_name = "UPPERCASEREMOTE"

def test(self):
remote_url = get_local_storagepath()
remote_url = Local.get_storagepath()
ret = main(["remote", "add", self.upper_case_remote_name, remote_url])
self.assertEqual(ret, 0)

Expand Down
25 changes: 12 additions & 13 deletions tests/remotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,16 @@
TEST_GDRIVE_CLIENT_SECRET = "2fy_HyzSwkxkGzEken7hThXb"


def get_local_storagepath():
return TestDvc.mkdtemp()


def get_local_url():
return get_local_storagepath()


class Local:
should_test = lambda: True # noqa: E731
get_url = get_local_url

@staticmethod
def get_storagepath():
return TestDvc.mkdtemp()

@staticmethod
def get_url():
return Local.get_storagepath()


class S3:
Expand Down Expand Up @@ -215,7 +214,7 @@ def should_test():
@staticmethod
def get_url():
return "ssh://{}@127.0.0.1:22{}".format(
getpass.getuser(), get_local_storagepath()
getpass.getuser(), Local.get_storagepath()
)


Expand All @@ -224,9 +223,9 @@ class SSHMocked:

@staticmethod
def get_url(user, port):
path = get_local_storagepath()
path = Local.get_storagepath()
if os.name == "nt":
# NOTE: On Windows get_local_storagepath() will return an
# NOTE: On Windows Local.get_storagepath() will return an
# ntpath that looks something like `C:\some\path`, which is not
# compatible with SFTP paths [1], so we need to convert it to
# a proper posixpath.
Expand Down Expand Up @@ -273,5 +272,5 @@ def should_test():
@staticmethod
def get_url():
return "hdfs://{}@127.0.0.1{}".format(
getpass.getuser(), get_local_storagepath()
getpass.getuser(), Local.get_storagepath()
)