tests: create remote fixtures (#4063)

* tests: use remote fixtures

* tests: use remote fixtures for data cloud tests

* tests: treat remotes as tmp dirs
This commit is contained in:
Ruslan Kuprieiev
2020-06-18 01:36:13 +03:00
committed by GitHub
parent b579d06c8e
commit 51a8c782ae
31 changed files with 845 additions and 1092 deletions
+1 -34
View File
@@ -1,12 +1,9 @@
import os
import mockssh
import pytest
from dvc.remote.ssh.connection import SSHConnection
from tests.utils.httpd import PushRequestHandler, StaticFileServer
from .dir_helpers import * # noqa
from .remotes import * # noqa
# Prevent updater and analytics from running their processes
os.environ["DVC_TEST"] = "true"
@@ -28,39 +25,9 @@ def reset_loglevel(request, caplog):
yield
here = os.path.abspath(os.path.dirname(__file__))
user = "user"
key_path = os.path.join(here, f"{user}.key")
@pytest.fixture(scope="session")
def ssh_server():
users = {user: key_path}
with mockssh.Server(users) as s:
s.test_creds = {
"host": s.host,
"port": s.port,
"username": user,
"key_filename": key_path,
}
yield s
@pytest.fixture
def ssh(ssh_server):
yield SSHConnection(**ssh_server.test_creds)
@pytest.fixture(scope="session", autouse=True)
def _close_pools():
from dvc.remote.pool import close_pools
yield
close_pools()
@pytest.fixture
def http_server(tmp_dir):
with StaticFileServer(handler_class=PushRequestHandler) as httpd:
yield httpd