Skip to content

Fix failing tests: KeyError: 'relay_state' #2

Description

@basnijholt

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions