-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
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
Improved Homekit tests #12647
Conversation
@@ -108,17 +104,20 @@ def test_homekit_pyhap_interaction( | |||
|
|||
homekit.start_driver(Event(EVENT_HOMEASSISTANT_START)) | |||
|
|||
ip_address = get_local_ip() |
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.
Why use real one and not a fake one?
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.
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?
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.
Maybe a future restructure should address the start_driver
method. Currently it handles basically everything at startup.
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.
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.
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.
I use it to validate to the init
call to AccessoryDriver
since I mocked the whole class. L113
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.
with patch('blabla.get_local_ip', return_value='127.0.0.1'):
homekit.start_driver(Event(EVENT_HOMEASSISTANT_START))
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.
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.
Description:
Checklist: