Use python defaults for comparing State, LazyState, and Event objects (#86856)

* Speed up comparing State and Event objects

Use default python implementation for State and Event __hash__ and __eq__

The default implementation compared based on the id() of the object
which is effectively what we want here anyways. These overrides are
left over from the days when these used to be attrs objects

By avoiding implementing these ourselves all of the equality checks
can happen in native code

* tweak

* adjust tests

* write out some more

* fix test to not compare objects

* more test fixes

* more test fixes

* correct stats tests

* fix more tests

* fix more tests

* update sensor recorder tests
This commit is contained in:
J. Nick Koston 2023-01-29 08:31:43 -10:00 committed by GitHub
parent 80ffac48a3
commit c612a92cfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 389 additions and 174 deletions

View file

@ -30,8 +30,9 @@ async def test_api_list_state_entities(hass, mock_api_client):
assert resp.status == HTTPStatus.OK
json = await resp.json()
remote_data = [ha.State.from_dict(item) for item in json]
assert remote_data == hass.states.async_all()
remote_data = [ha.State.from_dict(item).as_dict() for item in json]
local_data = [state.as_dict() for state in hass.states.async_all()]
assert remote_data == local_data
async def test_api_get_state(hass, mock_api_client):