Skip to content
Merged

Scp #2660

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
addressing @ElDeveloper comments
  • Loading branch information
antgonza committed Sep 5, 2018
commit cbbf0883cabb9fb3db665b5940a7faf2d7ce5352
6 changes: 5 additions & 1 deletion qiita_ware/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def _ssh_session(p_url, private_key):
"""
scheme = p_url.scheme
hostname = p_url.hostname
port = p_url.port
# if port is '' Python 2.7.6 will raise an error
try:
port = p_url.port
except Exception:
port = 22
username = p_url.username

if scheme == 'scp' or scheme == 'sftp':
Expand Down
24 changes: 12 additions & 12 deletions qiita_ware/test/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ def setUp(self):
def tearDown(self):
rmtree(self.temp_local_dir)

def _get_valid_files(folder):
files = []
for x in qiita_config.valid_upload_extension:
files.extend([basename(f) for f in glob.glob('*.%s' % x)])
return files

def test_list_scp_wrong_key(self):
"""Tests remote file listing using a wrong private key and scp"""
with self.assertRaises(AuthenticationException):
Expand All @@ -62,36 +68,30 @@ def test_list_scp(self):
"""Tests remote file listing using private key and scp"""
read_file_list = list_remote('scp://localhost:'+self.remote_dir_path,
self.test_ssh_key)
remote_filename_list = [basename(f) for f in
glob(join(self.remote_dir_path, '*'))]
remote_filename_list = self._get_valid_files(self.remote_dir_path)
self.assertEqual(remote_filename_list, read_file_list)

def test_list_sftp(self):
"""Tests remote file listing using private key and sftp"""
read_file_list = list_remote('sftp://localhost:'+self.remote_dir_path,
self.test_ssh_key)
remote_filename_list = [basename(f) for f in
glob(join(self.remote_dir_path, '*'))]
remote_filename_list = self._get_valid_files(self.remote_dir_path)
self.assertEqual(remote_filename_list, read_file_list)

def test_download_scp(self):
"""Tests remote file listing using private key and scp"""
download_remote('scp://localhost:'+self.remote_dir_path,
self.test_ssh_key, self.temp_local_dir)
remote_filename_list = [basename(f) for f in
glob(join(self.remote_dir_path, '*'))]
local_filename_list = [basename(f) for f in
glob(join(self.temp_local_dir, '*'))]
remote_filename_list = self._get_valid_files(self.remote_dir_path)
local_filename_list = self._get_valid_files(self.temp_local_dir)
self.assertEqual(remote_filename_list, local_filename_list)

def test_download_sftp(self):
"""Tests remote file listing using private key and sftp"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this was my previous comment:

should be Tests remote file downloading ...

I think we stopped adding docstrings to test cases so I would suggest removing them altogether.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

K

download_remote('sftp://localhost:'+self.remote_dir_path,
self.test_ssh_key, self.temp_local_dir)
remote_filename_list = [basename(f) for f in
glob(join(self.remote_dir_path, '*'))]
local_filename_list = [basename(f) for f in
glob(join(self.temp_local_dir, '*'))]
remote_filename_list = self._get_valid_files(self.remote_dir_path)
local_filename_list = self._get_valid_files(self.temp_local_dir)
self.assertEqual(remote_filename_list, local_filename_list)


Expand Down
Empty file.