mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
ls-url: remove redundant tests
This commit is contained in:
committed by
Ruslan Kuprieiev
parent
4a558edc59
commit
a6cdb9efd2
@@ -1,56 +1,5 @@
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from dvc.exceptions import URLMissingError
|
||||
from dvc.repo import Repo
|
||||
from dvc.testing.workspace_tests import TestLsUrl as _TestLsUrl
|
||||
|
||||
|
||||
def match_files(entries, expected):
|
||||
entries_content = {(d["path"], d["isdir"]) for d in entries}
|
||||
expected_content = {
|
||||
(os.path.normpath(d["path"]), d["isdir"]) for d in expected
|
||||
}
|
||||
assert entries_content == expected_content
|
||||
|
||||
|
||||
@pytest.mark.parametrize("fname", ["foo", "foo.dvc", "dir/foo"])
|
||||
def test_file(tmp_dir, fname):
|
||||
tmp_dir.gen({fname: "foo contents"})
|
||||
|
||||
(d,) = Repo.ls_url(fname)
|
||||
assert d["isdir"] is False
|
||||
assert os.path.normpath(d["path"]) == os.path.abspath(fname)
|
||||
|
||||
|
||||
def test_dir(tmp_dir):
|
||||
tmp_dir.gen({"dir/foo": "foo contents", "dir/subdir/bar": "bar contents"})
|
||||
|
||||
result = Repo.ls_url("dir")
|
||||
match_files(
|
||||
result,
|
||||
[{"path": "foo", "isdir": False}, {"path": "subdir", "isdir": True}],
|
||||
)
|
||||
|
||||
|
||||
def test_recursive(tmp_dir):
|
||||
tmp_dir.gen({"dir/foo": "foo contents", "dir/subdir/bar": "bar contents"})
|
||||
|
||||
result = Repo.ls_url("dir", recursive=True)
|
||||
match_files(
|
||||
result,
|
||||
[
|
||||
{"path": "foo", "isdir": False},
|
||||
{"path": "subdir/bar", "isdir": False},
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def test_nonexistent(tmp_dir):
|
||||
with pytest.raises(URLMissingError):
|
||||
Repo.ls_url("nonexistent")
|
||||
|
||||
|
||||
class TestLsUrl(_TestLsUrl):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user