Skip to content

Commit ab84a40

Browse files
committed
Refactor ssh connection set up tests.
1 parent 4a6cf59 commit ab84a40

File tree

6 files changed

+7
-113
lines changed

6 files changed

+7
-113
lines changed

datashuttle/configs/config_class.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ def update_config_for_backward_compatability_if_required(
169169
if config_dict["connection_method"] is None:
170170
config_dict["connection_method"] = "local_only"
171171

172-
def save_rclone_password_state(self):
173-
with open(self.rclone_password_state_file_path, "w") as file:
174-
yaml.dump(self.rclone_has_password, file)
175-
176172
# -------------------------------------------------------------------------
177173
# Utils
178174
# -------------------------------------------------------------------------

datashuttle/datashuttle_class.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,8 @@ def _setup_rclone_central_ssh_config(
16861686

16871687
def _setup_rclone_central_local_filesystem_config(self) -> None:
16881688
rclone.setup_rclone_config_for_local_filesystem(
1689-
self.cfg, self.cfg.rclone.get_rclone_config_name("local_filesystem"),
1689+
self.cfg,
1690+
self.cfg.rclone.get_rclone_config_name("local_filesystem"),
16901691
)
16911692

16921693
def _setup_rclone_gdrive_config(

datashuttle/utils/rclone.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ def setup_rclone_config_for_ssh(
303303
if log:
304304
log_rclone_config_output(cfg)
305305

306+
306307
def setup_rclone_config_for_gdrive(
307308
cfg: Configs,
308309
rclone_config_name: str,
@@ -493,16 +494,6 @@ def setup_rclone_config_for_aws(
493494
if log:
494495
log_rclone_config_output(cfg)
495496

496-
def delete_existing_rclone_config_file(cfg: Configs):
497-
""" """
498-
rclone_config_filepath = (
499-
cfg.rclone.get_rclone_central_connection_config_filepath()
500-
)
501-
502-
if rclone_config_filepath.exists():
503-
rclone_config_filepath.unlink()
504-
cfg.rclone.set_rclone_has_password(False)
505-
506497

507498
def get_config_arg(cfg: Configs) -> str:
508499
"""Get the full argument to run Rclone commands with a specific config."""

tests/tests_transfers/ssh/ssh_test_utils.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import subprocess
44
import sys
55

6-
from datashuttle.utils import rclone, ssh, utils
6+
from datashuttle.utils import utils
77

88

99
def setup_project_for_ssh(
@@ -23,7 +23,7 @@ def setup_project_for_ssh(
2323
)
2424

2525

26-
def setup_ssh_connection(project, setup_ssh_key_pair=True):
26+
def setup_ssh_connection(project):
2727
"""
2828
Convenience function to verify the server hostkey and ssh
2929
key pairs to the Dockerfile image for ssh tests.
@@ -46,27 +46,13 @@ def setup_ssh_connection(project, setup_ssh_key_pair=True):
4646
orig_isatty = copy.deepcopy(sys.stdin.isatty)
4747
sys.stdin.isatty = lambda: True
4848

49-
# Run setup
50-
verified = ssh.verify_ssh_central_host_api(
51-
project.cfg["central_host_id"], project.cfg.hostkeys_path, log=True
52-
)
53-
54-
if setup_ssh_key_pair:
55-
private_key_str = ssh.setup_ssh_key_api(project.cfg, log=False)
56-
57-
rclone.setup_rclone_config_for_ssh(
58-
project.cfg,
59-
project.cfg.rclone.get_rclone_config_name("ssh"),
60-
private_key_str,
61-
)
49+
project.setup_ssh_connection()
6250

6351
# Restore functions
6452
builtins.input = orig_builtin
6553
utils.get_connection_secret_from_user = orig_get_secret
6654
sys.stdin.isatty = orig_isatty
6755

68-
return verified
69-
7056

7157
def docker_is_running():
7258
if not is_docker_installed():

tests/tests_transfers/ssh/test_ssh_setup.py

Lines changed: 0 additions & 81 deletions
This file was deleted.

tests/tests_transfers/ssh/test_ssh_suggest_next.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ def ssh_setup(self, setup_project_paths, setup_ssh_container_fixture):
2727
Setup pathtable and project for SSH transfer tests.
2828
"""
2929
project = test_utils.make_project(setup_project_paths["project_name"])
30+
3031
ssh_test_utils.setup_project_for_ssh(
3132
project,
3233
)

0 commit comments

Comments
 (0)