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

Fix failing tests: KeyError: 'relay_state' #2

Closed
basnijholt opened this issue Dec 18, 2019 · 2 comments
Closed

Fix failing tests: KeyError: 'relay_state' #2

basnijholt opened this issue Dec 18, 2019 · 2 comments

Comments

@basnijholt
Copy link
Contributor

In the CI's build log I see:

2019-12-18T08:07:23.5192675Z 
2019-12-18T08:07:23.5192766Z =================================== FAILURES ===================================
2019-12-18T08:07:23.5192838Z _ test_state_info[/home/vsts/work/1/s/kasa/tests/fixtures/HS300(US)_1.0.json] __
2019-12-18T08:07:23.5193293Z 
2019-12-18T08:07:23.5194008Z dev = <[KeyError('relay_state') raised in repr()] SmartStrip object at 0x7f5dd51ed290>
2019-12-18T08:07:23.5194070Z 
2019-12-18T08:07:23.5194611Z     def test_state_info(dev):
2019-12-18T08:07:23.5194668Z         dev.sync.update()
2019-12-18T08:07:23.5194738Z >       assert isinstance(dev.sync.state_information, dict)
2019-12-18T08:07:23.5194781Z 
2019-12-18T08:07:23.5194830Z kasa/tests/test_fixtures.py:59: 
2019-12-18T08:07:23.5194904Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2019-12-18T08:07:23.5194968Z kasa/smartdevice.py:674: in __getattr__
2019-12-18T08:07:23.5195381Z     method = getattr(self.async_device, attr)
2019-12-18T08:07:23.5195440Z kasa/smartdevice.py:98: in wrapped
2019-12-18T08:07:23.5195599Z     return f(*args, **kwargs)
2019-12-18T08:07:23.5195668Z kasa/smartstrip.py:120: in state_information
2019-12-18T08:07:23.5195725Z     if plug.is_on:
2019-12-18T08:07:23.5195786Z kasa/smartdevice.py:98: in wrapped
2019-12-18T08:07:23.5195842Z     return f(*args, **kwargs)
2019-12-18T08:07:23.5195906Z _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
2019-12-18T08:07:23.5195959Z 
2019-12-18T08:07:23.5198186Z self = <[KeyError('relay_state') raised in repr()] SmartPlug object at 0x7f5dd51ed1d0>
2019-12-18T08:07:23.5198257Z 
2019-12-18T08:07:23.5198322Z     @property  # type: ignore
2019-12-18T08:07:23.5198369Z     @requires_update
2019-12-18T08:07:23.5198606Z     def is_on(self) -> bool:
2019-12-18T08:07:23.5198660Z         """Return whether device is on.
2019-12-18T08:07:23.5198707Z     
2019-12-18T08:07:23.5198775Z         :return: True if device is on, False otherwise
2019-12-18T08:07:23.5198825Z         """
2019-12-18T08:07:23.5198883Z         sys_info = self.sys_info
2019-12-18T08:07:23.5198933Z >       return bool(sys_info["relay_state"])
2019-12-18T08:07:23.5199132Z E       KeyError: 'relay_state'

@rytilahti, this was after you simplified the socket strip. Do you perhaps know why this happens?

@rytilahti
Copy link
Member

According to the dummy fixture, HS300 does not have a relay state (https://github.com/python-kasa/python-kasa/blob/master/kasa/tests/fixtures/HS300(US)_1.0.json), I'm not really sure if that's really the case as the strip has set_relay_state (https://github.com/python-kasa/python-kasa/blob/master/kasa/smartstrip.py#L93).

It could just be that this was not implemented in https://github.com/plasticrake/tplink-smarthome-simulator which I used to generate those files, so I'm hoping someone with HS300 will deliver us a devinfo dump from a real device. For the time being we could simply skip that test with a warning for strip devices.

@rytilahti rytilahti added this to the Initial release milestone Jan 12, 2020
@rytilahti
Copy link
Member

This was fixed with #14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants