8000 Improved Homekit tests by cdce8p · Pull Request #12647 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improved Homekit tests #12647

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

Merged
merged 4 commits into from
Feb 25, 2018
Merged

Improved Homekit tests #12647

merged 4 commits into from
Feb 25, 2018

Conversation

cdce8p
Copy link
Member
@cdce8p cdce8p commented Feb 24, 2018

Description:

  • Fix to travis import error
  • Fixed spelling and typos

Checklist:

  • The code change is tested and works locally.

@cdce8p cdce8p changed the title WIP: Improved Homekit tests Improved Homekit tests Feb 25, 2018
@@ -108,17 +104,20 @@ def test_homekit_pyhap_interaction(

homekit.start_driver(Event(EVENT_HOMEASSISTANT_START))

ip_address = get_local_ip()
Copy link
Member

Choose a reason for hiding this comment

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

Why use real one and not a fake one?

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess I could mock get_local_ip as well, but the call is in HomeKit.start_driver so I can't just set one, or can I?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe a future restructure should address the start_driver method. Currently it handles basically everything at startup.

Copy link
Member

Choose a reason for hiding this comment

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

Well, it's actually already auto-mocked in conftest.py but still kinda weird that it's needed. I much rather see a patch context manager wrapped around the instantiating code to mock it explicitly.

Copy link
Member Author

Choose a reason for hiding this comment

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

I use it to validate to the init call to AccessoryDriver since I mocked the whole class. L113

Copy link
Member

Choose a reason for hiding this comment

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

with patch('blabla.get_local_ip', return_value='127.0.0.1'):
    homekit.start_driver(Event(EVENT_HOMEASSISTANT_START))

Copy link
Member Author

Choose a reason for hiding this comment

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

patch context manager would be nice. I'm relatively new to mocking and didn't had a chance to get it to work the way I wanted to. Thats why I left it as it is now.

@cdce8p cdce8p merged commit eacfbc0 into home-assistant:dev Feb 25, 2018
@cdce8p cdce8p deleted the homekit-tests branch February 25, 2018 09:58
@balloob balloob mentioned this pull request Mar 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0