Skip to content

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
raman325 committed Mar 24, 2024
1 parent a966258 commit 09b0873
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tests/virtual/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,28 @@ async def test_door_lock(hass: HomeAssistant):
assert lock._data == {}
await lock.async_hard_refresh_codes()
assert lock._data == {}
# we should not be able to clear a usercode that does not exist
with pytest.raises(HomeAssistantError):
await lock.async_clear_usercode(1)
assert lock.usercode_scan_interval == timedelta(minutes=1)

# we should be able to set a usercode and see it in the data
await lock.async_set_usercode(1, 1, "test")
assert lock._data["1"] == {"code": 1, "name": "test"}
await lock.async_get_usercodes()
assert lock._data["1"] == {"code": 1, "name": "test"}

# if we unload without removing permanently, the data should be saved
assert await lock.async_unload(False) is None
assert await lock.async_setup() is None
assert lock._data["1"] == {"code": 1, "name": "test"}

# we can clear a valid usercode
await lock.async_set_usercode(2, 2, "test2")
assert lock._data["2"] == {"code": 2, "name": "test2"}
await lock.async_clear_usercode(2)
assert "2" not in lock._data

# if we unload with removing permanently, the data should be removed
assert await lock.async_unload(True) is None
assert await lock.async_setup() is None
assert not lock._data

0 comments on commit 09b0873

Please sign in to comment.