mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-02 07:18:25 +01:00
test: func: use pytest for outputs/dependencies
Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
@@ -1,15 +1,21 @@
|
||||
import copy
|
||||
import pytest
|
||||
|
||||
from dvc.stage import Stage
|
||||
from dvc.dependency import _get, DEP_MAP
|
||||
|
||||
from tests.func.test_output import TestOutScheme
|
||||
from tests.func.test_output import TESTS as OUT_TESTS
|
||||
|
||||
|
||||
class TestDepScheme(TestOutScheme):
|
||||
MAP = DEP_MAP
|
||||
TESTS = copy.copy(OUT_TESTS)
|
||||
TESTS.append(("http://example.com/path/to/file", "http"))
|
||||
TESTS.append(("https://example.com/path/to/file", "https"))
|
||||
|
||||
TESTS = TestOutScheme.TESTS.copy()
|
||||
TESTS["http://example.com/path/to/file"] = "http"
|
||||
TESTS["https://example.com/path/to/file"] = "https"
|
||||
|
||||
def _get(self, path):
|
||||
return _get(Stage(self.dvc), path, None)
|
||||
def _get_dep(dvc, path):
|
||||
return _get(Stage(dvc), path, None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("url,scheme", TESTS)
|
||||
def test_scheme(dvc, url, scheme):
|
||||
assert type(_get_dep(dvc, url)) == DEP_MAP[scheme]
|
||||
|
||||
+22
-23
@@ -1,30 +1,29 @@
|
||||
import pytest
|
||||
|
||||
from dvc.stage import Stage
|
||||
from dvc.output import _get, OUTS_MAP
|
||||
|
||||
from tests.basic_env import TestDvc
|
||||
|
||||
TESTS = [
|
||||
("s3://bucket/path", "s3"),
|
||||
("gs://bucket/path", "gs"),
|
||||
("ssh://example.com:/dir/path", "ssh"),
|
||||
("hdfs://example.com/dir/path", "hdfs"),
|
||||
("path/to/file", "local"),
|
||||
("path\\to\\file", "local"),
|
||||
("file", "local"),
|
||||
("./file", "local"),
|
||||
(".\\file", "local"),
|
||||
("../file", "local"),
|
||||
("..\\file", "local"),
|
||||
("unknown://path", "local"),
|
||||
]
|
||||
|
||||
|
||||
class TestOutScheme(TestDvc):
|
||||
MAP = OUTS_MAP
|
||||
def _get_out(dvc, path):
|
||||
return _get(Stage(dvc), path, None, None, None, None)
|
||||
|
||||
TESTS = {
|
||||
"s3://bucket/path": "s3",
|
||||
"gs://bucket/path": "gs",
|
||||
"ssh://example.com:/dir/path": "ssh",
|
||||
"hdfs://example.com/dir/path": "hdfs",
|
||||
"path/to/file": "local",
|
||||
"path\\to\\file": "local",
|
||||
"file": "local",
|
||||
"./file": "local",
|
||||
".\\file": "local",
|
||||
"../file": "local",
|
||||
"..\\file": "local",
|
||||
"unknown://path": "local",
|
||||
}
|
||||
|
||||
def _get(self, path):
|
||||
return _get(Stage(self.dvc), path, None, None, None, None)
|
||||
|
||||
def test(self):
|
||||
for path, cls in self.TESTS.items():
|
||||
self.assertIsInstance(self._get(path), self.MAP[cls])
|
||||
@pytest.mark.parametrize("url,scheme", TESTS)
|
||||
def test_scheme(dvc, url, scheme):
|
||||
assert type(_get_out(dvc, url)) == OUTS_MAP[scheme]
|
||||
|
||||
Reference in New Issue
Block a user