-
-
Notifications
You must be signed in to change notification settings - Fork 227
Add plumbing for passing credentials to devices #507
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
Add plumbing for passing credentials to devices #507
Conversation
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.
Looks good to me! I think the smartdevice ctor change should also go into this PR, as that will allow writing some unittests to make sure it's all working as expected.
Now done. Also changed the default of username and password to None and removed the check in discovery for 255 as per comments on #477. Also had to tweak the cli handling of the json parameter because tests failed if they appeared after the test_json_output because echo remained a noop |
Codecov ReportPatch coverage is
📢 Thoughts on this report? Let us know!. |
Hi @rytilahti, any thoughts on the latest here? It should have everything you wanted now. |
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.
Thanks for the ping, I've been busy and forgot to reply here earlier. Would you mind adding a parametrized test for the constructors of smartdevice classes to verify that the input parameters are stored as expected?
I think I have done this by passing in all the discovery fixtures and calling cli with the --type parameter. |
It's more important to test against the API as that's likely more consumed by external users than the cli tool. Tests for both are obviously better, but the API takes priority. |
Ok, so a test that creates an instance itself and then checks the credentials are there? With parameters of all the possible derived classes of SmartDevice? |
Something like this should suffice, the idea is just to avoid breaking that API by chance:
I'm not sure which file it should go to, though... |
Ok so added this test to test_smartdevice.py. |
Do you mean override it for every test other than json? The issue here is that if any test runs after the json test then the global echo is still set to noop. It just happens I'm the first person to add a test after the json test. (I guess this could affect any other code calling the cli module directly but not sure if that's a use case) Another way to do it without introducing another global could be to introduce a function that gets the echo function:
Then just:
|
I don't currently have the energy nor the time to dig into that, so let's just add a comment, keep it as it is for now and let's get this merged (after fixing the test that does not really test the real output) :-) |
That's done. Re: the test that doesn't check the real output it does check that credentials when properly supplied are passed from the cli to the device so I think this should be good to go |
Add credentials classes and cli support to support future implementation of authenticating protocols. See #477 for discussion