Skip to content

Commit

Permalink
tests: adjust tests
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Apr 23, 2020
1 parent f1a413d commit 524bf13
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 48 deletions.
5 changes: 2 additions & 3 deletions tests/func/test_cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import stat
from pathlib import Path

import configobj
import pytest
Expand Down Expand Up @@ -155,7 +154,7 @@ def test_abs_path(self):
self.assertEqual(ret, 0)

config = configobj.ConfigObj(self.dvc.config.files["repo"])
self.assertEqual(Path(config["cache"]["dir"]), Path(dname))
self.assertEqual(config["cache"]["dir"], dname.replace("\\", "/"))

def test_relative_path(self):
tmpdir = self.mkdtemp()
Expand All @@ -167,7 +166,7 @@ def test_relative_path(self):
# dir path written to config should be just one level above.
rel = os.path.join("..", dname)
config = configobj.ConfigObj(self.dvc.config.files["repo"])
self.assertEqual(Path(config["cache"]["dir"]), Path(rel))
self.assertEqual(config["cache"]["dir"], rel.replace("\\", "/"))

ret = main(["add", self.FOO])
self.assertEqual(ret, 0)
Expand Down
12 changes: 6 additions & 6 deletions tests/func/test_remote.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import errno
import os
import posixpath

import configobj
import pytest
from mock import patch

from dvc.compat import fspath
from dvc.config import Config
from dvc.exceptions import DownloadError, UploadError
from dvc.main import main
from dvc.path_info import PathInfo
from dvc.remote import RemoteLOCAL
from dvc.remote.base import RemoteBASE, RemoteCacheRequiredError
from dvc.compat import fspath
from dvc.utils.fs import remove
from tests.basic_env import TestDvc
from tests.remotes import Local
Expand Down Expand Up @@ -40,16 +39,17 @@ def test(self):
self.assertEqual(main(["remote", "list"]), 0)

def test_relative_path(self):
dname_parts = ["..", "path", "to", "dir"]
dname = os.path.join(*dname_parts)
dname = os.path.join("..", "path", "to", "dir")
ret = main(["remote", "add", "mylocal", dname])
self.assertEqual(ret, 0)

# NOTE: we are in the repo's root and config is in .dvc/, so
# dir path written to config should be just one level above.
rel = posixpath.join("..", *dname_parts)
rel = os.path.join("..", dname)
config = configobj.ConfigObj(self.dvc.config.files["repo"])
self.assertEqual(config['remote "mylocal"']["url"], rel)
self.assertEqual(
config['remote "mylocal"']["url"], rel.replace("\\", "/")
)

def test_overwrite(self):
remote_name = "a"
Expand Down
39 changes: 0 additions & 39 deletions tests/unit/command/test_config.py

This file was deleted.

17 changes: 17 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
import pytest

from dvc.config import Config


@pytest.mark.parametrize(
"path, expected",
[
("cache", "../cache"),
(os.path.join("..", "cache"), "../../cache"),
(os.getcwd(), os.getcwd().replace("\\", "/")),
("ssh://some/path", "ssh://some/path"),
],
)
def test_to_relpath(path, expected):
assert Config._to_relpath(os.path.join(".", "config"), path) == expected

0 comments on commit 524bf13

Please sign in to comment.