-
-
Notifications
You must be signed in to change notification settings - Fork 561
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
Make discovery to work with no IP addr and token, courtesy of M0ses #198
Conversation
miio/click_common.py
Outdated
@@ -25,6 +26,7 @@ def validate_ip(ctx, param, value): | |||
|
|||
|
|||
def validate_token(ctx, param, value): | |||
if value is None: return 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.
multiple statements on one line (colon)
miio/click_common.py
Outdated
@@ -17,6 +17,7 @@ | |||
|
|||
|
|||
def validate_ip(ctx, param, value): | |||
if value is None: return 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.
multiple statements on one line (colon)
LGTM, but maybe adding my test cases in an adapted version would make sense and could avoid regressions |
miio/tests/test_click_common.py
Outdated
|
||
def test_validate_ip_empty(): | ||
assert validate_ip(None, None, None) is 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.
blank line at end of file
miio/tests/test_click_common.py
Outdated
assert not validate_token(None, None, None) | ||
|
||
def test_validate_ip_empty(): | ||
assert validate_ip(None, None, None) is 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.
'validate_ip' may be undefined, or defined from star imports: miio.click_common
miio/tests/test_click_common.py
Outdated
def test_validate_token_empty(): | ||
assert not validate_token(None, None, None) | ||
|
||
def test_validate_ip_empty(): |
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.
expected 2 blank lines, found 1
miio/tests/test_click_common.py
Outdated
from miio.click_common import * | ||
|
||
def test_validate_token_empty(): | ||
assert not validate_token(None, None, 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.
'validate_token' may be undefined, or defined from star imports: miio.click_common
miio/tests/test_click_common.py
Outdated
@@ -0,0 +1,8 @@ | |||
from miio.click_common import * | |||
|
|||
def test_validate_token_empty(): |
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.
expected 2 blank lines, found 1
miio/tests/test_click_common.py
Outdated
@@ -0,0 +1,8 @@ | |||
from miio.click_common import * |
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.
'from miio.click_common import *' used; unable to detect undefined names
miio/tests/test_click_common.py
Outdated
|
||
def test_validate_ip_empty(): | ||
assert validate_ip(None, None, None) is 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.
blank line at end of file
miio/tests/test_click_common.py
Outdated
assert not validate_token(None, None, None) | ||
|
||
def test_validate_ip_empty(): | ||
assert validate_ip(None, None, None) is 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.
'validate_ip' may be undefined, or defined from star imports: miio.click_common
miio/tests/test_click_common.py
Outdated
def test_validate_token_empty(): | ||
assert not validate_token(None, None, None) | ||
|
||
def test_validate_ip_empty(): |
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.
expected 2 blank lines, found 1
miio/tests/test_click_common.py
Outdated
from miio.click_common import * | ||
|
||
def test_validate_token_empty(): | ||
assert not validate_token(None, None, 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.
'validate_token' may be undefined, or defined from star imports: miio.click_common
miio/tests/test_click_common.py
Outdated
@@ -0,0 +1,8 @@ | |||
from miio.click_common import * | |||
|
|||
def test_validate_token_empty(): |
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.
expected 2 blank lines, found 1
miio/tests/test_click_common.py
Outdated
@@ -0,0 +1,8 @@ | |||
from miio.click_common import * |
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.
'from miio.click_common import *' used; unable to detect undefined names
Good point! I renamed the file (hopefully there'll be more tests for that part of the code) and changed test to assert with 'is' instead of '=='. Thanks for the patch! |
|
||
def test_validate_ip_empty(): | ||
assert validate_ip(None, None, None) is 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.
blank line at end of file
Thanks for fixing. Just some nitpicking: Wouldn`t it make sense to change https://github.com/rytilahti/python-miio/pull/198/files#diff-57c62bdfa1f30df2fde08081703b47c5R5 to
as done below in https://github.com/rytilahti/python-miio/pull/198/files#diff-57c62bdfa1f30df2fde08081703b47c5R9 to be more consistent in coding? BTW: I built rpm packages for openSUSE https://build.opensuse.org/project/show/home:M0ses:miio for those who want to try it on tumbleweed |
Yeah, I think it would have made sense to compare both to is None, considering that "not" doesn't compare to Noneness but to trueness/falseness. That can probably be fixed at some point when new tests get added to that suite, I think it's not worth to change it for now. Thanks for the packaging! If you want, the README could be updated to point to available packaging, I think archlinux has also a package available :-) |
Obsoletes #194