-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Crypto import and update tests #28
Conversation
ca17030
to
1e9c4a6
Compare
ska_ftp/tests/test_basic.py
Outdated
@@ -90,7 +89,7 @@ def test_delete_when_ftp_session_already_gone(capfd): | |||
def test_parse_netrc(): | |||
cwd = os.path.dirname(__file__) | |||
netrc = ska_ftp.parse_netrc(os.path.join(cwd, 'netrc')) | |||
assert netrc == {'test1': {'account': None, | |||
assert netrc == {'test1': {'account': '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this should be updated to have different values for different versions of netrc . I think what we're seeing lines up with https://docs.python.org/3/library/netrc.html "changed in version 3.10" .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked in detail, but my first reaction is that we should try to maintain API compatibility in ska_ftp
, if possible. If it is a huge pain then we can reconsider.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So would you want to code around the change in netrc.netrc to introduce api back compatibility for ska_ftp.parse_netrc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this some more, we are unlikely to see this cause much of problem in the wild. Basically our users are going to either have a complete netrc entry or not all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I couldn't think of a use case where we would be asking the netrc file for credentials when the user or password (credential pair) is incomplete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have this test compare to two possible reference results, one with None
and the other with ''
. Either that, or do something to figure out which netrc version is present, and then use the right reference reult.
That way we can merge now instead of juggle that together with the speedy transition.
ska_ftp/tests/test_basic.py
Outdated
LUCKY = 'lucky.cfa.harvard.edu' | ||
|
||
|
||
def roundtrip(FtpClass, logger=None): | ||
def roundtrip(NETRC, FtpClass, logger=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use an all-caps here, especially since it masks a global value (fixture) making things super confusing.
Optionally also change FtpClass
to ftp_cls
to comply with modern naming standards.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree about not using all-caps here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving this with a lien on that one all-caps fix in the test. You can merge once that is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes requested in the comments:
- not to use NETRC in all-aps in function argument
- make it so the test passes in the current setup so it is not an extra thing to consider during the speedy transition
ska_ftp/tests/test_basic.py
Outdated
LUCKY = 'lucky.cfa.harvard.edu' | ||
|
||
|
||
def roundtrip(FtpClass, logger=None): | ||
def roundtrip(NETRC, FtpClass, logger=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree about not using all-caps here.
ska_ftp/tests/test_basic.py
Outdated
@@ -90,7 +89,7 @@ def test_delete_when_ftp_session_already_gone(capfd): | |||
def test_parse_netrc(): | |||
cwd = os.path.dirname(__file__) | |||
netrc = ska_ftp.parse_netrc(os.path.join(cwd, 'netrc')) | |||
assert netrc == {'test1': {'account': None, | |||
assert netrc == {'test1': {'account': '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have this test compare to two possible reference results, one with None
and the other with ''
. Either that, or do something to figure out which netrc version is present, and then use the right reference reult.
That way we can merge now instead of juggle that together with the speedy transition.
Regarding "make it so the test passes in the current setup so it is not an extra thing to consider during the speedy transition" -- we can make that one-test pass both ways if you like. If we remove the Crypto import and warnings filter here I assume you'd need an update to the global pytest ini to pass ska_testr warnings checking for the Python 3.10 case. |
and if we were to make another 2023.* release, we might have to add the ignore to the ska environment in ska_helpers, but we would be done with this. |
OK, I renamed the fixture to parsed_netrc and updated that comparison test to work with either '' or None for an empty account value. We could also remove the test with an empty account as it seems not relevant to our use cases as noted. |
Unfortunately the naming issue is still there. The main point was that the fixture should have a different name than the argument in You had named the fixture in all-caps, and that is arguably ok because it is a global, so Tom's request was to change the all-caps only in the Now they are both lower-case, but they should be different. Sorry. |
Oh OK, I'll just rename it in roundtrip(). And yes, I considered that the fixture really wasn't that different from the global that I replaced it with when I left it named NETRC but missed the point that the local test function roundtrip() doesn't need access to the fixture because it is supplied directly by the test and the naming gets a bit confusing there. Granted they all get basically the same thing and I didn't fix some of the issues of scope that existed before I started here. I did not come across good advice for fixture naming in my limited googling. |
If the preference is that the fixture is named NETRC I'll go back to that -- I don't feel strongly here about the naming I just really didn't like the global NETRC. |
Maybe with this netrc fixture it would make more sense to use the usefixtures decorator. |
OK, per our morning conversation I left the pytest fixtures implemented as arguments, renamed FtpClass to ftp_cls, and reran the tests on ska3-masters and the ska3 speedy candidate. I'll go ahead and merge this. |
Oh, I forgot I'll need a new review status from Javier. |
Description
Remove Crypto import and update tests.
Crypto isn't available for Python 3.11 and we weren't really using it anyway. A more fundamental issue is that it looks like netrc.netrc is now returning empty string instead of None if a value isn't in the netrc, so this isn't 100% back-compatible behavior (and the test isn't back-compatible).
Fixes issue like
on Python 3.11 test build. May have more warnings again on Python 3.10 build but we catch those with pytest.ini anyway.
Interface impacts
test_parse_netrc has been updated for netrc version >= 3.10 which returns empty string instead of None and is not compatible with current ska3-flight.
Testing
Unit tests
Independent check of unit tests by [REVIEWER NAME]
Functional tests
No functional testing.