forked from datalad/datalad-extension-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This should be easier to use. The old implementation is now available in `ria_sshserver_setup` and should be considered internal. The new fixture returns the base RIA URL, and a local path to that same root directory (if one exists). It also sets `DATALAD_SSH_IDENTITYFILE`, which is needed by datalad-core's `SSHManager`. The setup may still need to use the `datalad_cfg` fixture, and possibly a dedicated reload to be effective. Closes #60
- Loading branch information
Showing
3 changed files
with
67 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
from .utils import assert_ssh_access | ||
from datalad_ria.tests.utils import assert_ssh_access | ||
|
||
# we import this one, rather than putting it into conftest.py, because | ||
# it is considered internal, in contrast to `ria_sshserver` | ||
from datalad_ria.tests.fixtures import ria_sshserver_setup | ||
|
||
def test_riaserver_fixture(ria_sshserver): | ||
|
||
def test_riaserver_setup_fixture(ria_sshserver_setup): | ||
# we run the same test that the fixture already ran, to verify that | ||
# the necessary information comes out of the fixture in a usable manner | ||
assert_ssh_access( | ||
ria_sshserver['HOST'], | ||
ria_sshserver['SSH_PORT'], | ||
ria_sshserver['SSH_LOGIN'], | ||
ria_sshserver['SSH_SECKEY'], | ||
ria_sshserver['SSH_PATH'], | ||
ria_sshserver['LOCALPATH'], | ||
ria_sshserver_setup['HOST'], | ||
ria_sshserver_setup['SSH_PORT'], | ||
ria_sshserver_setup['SSH_LOGIN'], | ||
ria_sshserver_setup['SSH_SECKEY'], | ||
ria_sshserver_setup['SSH_PATH'], | ||
ria_sshserver_setup['LOCALPATH'], | ||
) | ||
|
||
|
||
def test_riaserver_fixture(ria_sshserver): | ||
# base url and local path | ||
assert len(ria_sshserver) == 2 | ||
assert ria_sshserver[0].startswith('ria+ssh://') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from __future__ import annotations | ||
|
||
|
||
def build_ria_url( | ||
protocol: str, | ||
host: str, | ||
port: str | None = None, | ||
path: str | None = None, | ||
user: str | None = None, | ||
passwd: str | None = None, | ||
|
||
): | ||
if passwd and (user is None): | ||
raise ValueError('password without user name given') | ||
|
||
url = ( | ||
'ria+{protocol}://{user}{passdlm}{passwd}{userdlm}' | ||
'{host}{portdlm}{port}{pathdlm}{path}' | ||
).format( | ||
protocol=protocol, | ||
user=user or '', | ||
passdlm=':' if passwd else '', | ||
passwd=passwd or '', | ||
userdlm='@' if user else '', | ||
host=host or '', | ||
portdlm=':' if port else '', | ||
port=port or '', | ||
pathdlm='/' if path and not path.startswith('/') else '', | ||
path=path or '', | ||
) | ||
return url |