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

Device tracker component & platform validation. No more home_range. #2908

Merged
merged 8 commits into from
Aug 30, 2016

Conversation

kellerza
Copy link
Member

Description:
*Device tracker component & validation for platforms
*Removed home_range from device_tracker

Example entry for configuration.yaml (if applicable):

device_tracker:

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

if hasattr(platform, 'PLATFORM_SCHEMA'):
p_config = platform.PLATFORM_SCHEMA(p_config)
except vol.MultipleInvalid as ex:
_log_exception(ex, DOMAIN, p_config)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this function to remove the _ prefix. The convention is Python that _ prefix means that it's private to that module and should not be used.

@balloob
Copy link
Member

balloob commented Aug 20, 2016

Your commits seem weird for this PR? It includes secrets , vsure bump

@kellerza
Copy link
Member Author

I forced the "Mock, bluetooth" commit and it seemed to have caused issues. Will separate tomorrow

@balloob
Copy link
Member

balloob commented Aug 23, 2016

Bump :)

@kellerza
Copy link
Member Author

  • I fixed some feedback in "Fix feedback" patch (log_exception and made _component_value clearer)
    • Or should I rather remove the _component_value function in line 108? (It does help for validation though 😄)
  • With the validation bit I am stuck. And if I don't do it MQTT fails since no default values added by PLATFORM_SCHEMA
    • I've added a unit test for that (check if Qos is there) if you want to look into it. For this it might be better to look at bootstrap more and eventually remove it here.

conf = conf[0] if len(conf) > 0 else {}
def _component_value(key_name, default):
"""Retrieve a config value & ensure all platforms agree."""
res = list(set([plat[key_name] for plat in conf if key_name in plat]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't like this. Why even bother checking the other platforms ?

@robbiet480
Copy link
Member

@kellerza What's the status on this? Good to merge?

@kellerza
Copy link
Member Author

@robbiet480 Let me just add a test for the duplicate MAC / dev_id detection to at least keep coverage the same

@robbiet480
Copy link
Member

Hey @kellerza, got an update on this? Looks like tests just need to be fixed then it's good to go?

@kellerza
Copy link
Member Author

Seems like mock_f.assert_called_once() was removed in Python 3.5 and assert mock_f.call_count == 1 is the preferred way. I'll fix

@kellerza
Copy link
Member Author

@robbiet480 should be ok now. Coverage up 0.4%

device_tracker.Device(self.hass, True, True, 'your_device',
'AB:01', 'Your device', None, None, False)]
device_tracker.DeviceTracker(self.hass, False, True, devices)
print(mock_warning.call_args_list)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale print

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By design, or should I rather add it to the assert string below?

@Teagan42
Copy link
Contributor

🐬

@Teagan42 Teagan42 merged commit 55d3053 into home-assistant:dev Aug 30, 2016
@robbiet480 robbiet480 mentioned this pull request Aug 30, 2016
@kellerza kellerza deleted the dev_tracker branch September 3, 2016 20:02
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants