Skip to content
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

Merged
merged 4 commits into from Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions miio/click_common.py
Expand Up @@ -17,6 +17,8 @@


def validate_ip(ctx, param, value):
if value is None:
return None
try:
ipaddress.ip_address(value)
return value
Expand All @@ -25,6 +27,8 @@ def validate_ip(ctx, param, value):


def validate_token(ctx, param, value):
if value is None:
return None
token_len = len(value)
if token_len != 32:
raise click.BadParameter("Token length != 32 chars: %s" % token_len)
Expand Down
8 changes: 8 additions & 0 deletions miio/tests/test_click_common.py
@@ -0,0 +1,8 @@
from miio.click_common import *

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

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


def test_validate_token_empty():

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

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

assert not validate_token(None, None, None)

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

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


def test_validate_ip_empty():

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

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

assert validate_ip(None, None, None) is None

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

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


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

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

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