version: don't skip link info and skip if there is no psutil

Fixes #2336

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2019-07-29 03:33:07 +03:00
parent 32425e9069
commit 5e02a90e13
2 changed files with 32 additions and 18 deletions
+12 -12
View File
@@ -42,22 +42,22 @@ class CmdVersion(CmdBaseNoRepo):
binary=binary,
)
if psutil:
try:
repo = Repo()
root_directory = repo.root_dir
try:
repo = Repo()
root_directory = repo.root_dir
info += "Cache: {cache}\n".format(
cache=self.get_linktype_support_info(repo)
)
if psutil:
info += (
"Cache: {cache}\n"
"Filesystem type (cache directory): {fs_cache}\n"
).format(
cache=self.get_linktype_support_info(repo),
fs_cache=self.get_fs_type(repo.cache.local.cache_dir),
)
except NotDvcRepoError:
root_directory = os.getcwd()
).format(fs_cache=self.get_fs_type(repo.cache.local.cache_dir))
except NotDvcRepoError:
root_directory = os.getcwd()
if psutil:
info += ("Filesystem type (workspace): {fs_root}").format(
fs_root=self.get_fs_type(os.path.abspath(root_directory))
)
+20 -6
View File
@@ -1,6 +1,8 @@
import re
import pytest
from dvc.main import main
from dvc.command.version import psutil
def test_info_in_repo(dvc_repo, caplog):
@@ -10,15 +12,21 @@ def test_info_in_repo(dvc_repo, caplog):
assert re.search(re.compile(r"Python version: \d\.\d\.\d"), caplog.text)
assert re.search(re.compile(r"Platform: .*"), caplog.text)
assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
assert re.search(
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
)
@pytest.mark.skipif(psutil is None, reason="No psutil.")
def test_fs_info_in_repo(dvc_repo, caplog):
assert main(["version"]) == 0
assert re.search(
re.compile(r"Filesystem type \(cache directory\): .*"), caplog.text
)
assert re.search(
re.compile(r"Filesystem type \(workspace\): .*"), caplog.text
)
assert re.search(
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
)
def test_info_outside_of_repo(repo_dir, caplog):
@@ -28,12 +36,18 @@ def test_info_outside_of_repo(repo_dir, caplog):
assert re.search(re.compile(r"Python version: \d\.\d\.\d"), caplog.text)
assert re.search(re.compile(r"Platform: .*"), caplog.text)
assert re.search(re.compile(r"Binary: (True|False)"), caplog.text)
assert not re.search(
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
)
@pytest.mark.skipif(psutil is None, reason="No psutil.")
def test_fs_info_outside_of_repo(repo_dir, caplog):
assert main(["version"]) == 0
assert re.search(
re.compile(r"Filesystem type \(workspace\): .*"), caplog.text
)
assert not re.search(
re.compile(r"Filesystem type \(cache directory\): .*"), caplog.text
)
assert not re.search(
re.compile(r"(Cache: (.*link - (True|False)(,\s)?){3})"), caplog.text
)