test: func: use pytest for outputs/dependencies

Signed-off-by: Ruslan Kuprieiev <[email protected]>
This commit is contained in:
Ruslan Kuprieiev
2019-04-24 05:09:48 +03:00
parent 44b95f23a3
commit b97b99cf15
2 changed files with 36 additions and 31 deletions
+14 -8
View File
@@ -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
View File
@@ -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]