Skip to content

Commit

Permalink
Update tests to use NETRC fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanconn committed Dec 29, 2023
1 parent 1d264df commit 1e9c4a6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions ska_ftp/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import pytest
import ska_ftp

@pytest.fixture()
def NETRC():
return ska_ftp.parse_netrc()
13 changes: 6 additions & 7 deletions ska_ftp/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

logger = pyyaks.logger.get_logger()

NETRC = ska_ftp.parse_netrc()
LUCKY = 'lucky.cfa.harvard.edu'


def roundtrip(FtpClass, logger=None):
def roundtrip(NETRC, FtpClass, logger=None):
user = NETRC[LUCKY]['login']
homedir = ('/home/' if FtpClass is ska_ftp.SFTP else '/') + user
lucky = FtpClass(LUCKY, logger=logger)
Expand Down Expand Up @@ -42,17 +41,17 @@ def roundtrip(FtpClass, logger=None):
assert orig == roundtrip


def test_roundtrip():
def test_roundtrip(NETRC):
# roundtrip(FtpClass=ska_ftp.FTP, logger=logger) # legacy of non-secure ftp
roundtrip(FtpClass=ska_ftp.SFTP, logger=logger)
roundtrip(NETRC, FtpClass=ska_ftp.SFTP, logger=logger)


def test_roundtrip_no_logger():
def test_roundtrip_no_logger(NETRC):
# roundtrip(FtpClass=ska_ftp.FTP)
roundtrip(FtpClass=ska_ftp.SFTP)
roundtrip(NETRC, FtpClass=ska_ftp.SFTP)


def test_sftp_mkdir_rmdir_rename():
def test_sftp_mkdir_rmdir_rename(NETRC):
user = NETRC[LUCKY]['login']
homedir = '/home/{}'.format(user)
lucky = ska_ftp.SFTP(LUCKY, logger=logger)
Expand Down

0 comments on commit 1e9c4a6

Please sign in to comment.