@@ -28,23 +28,28 @@ async def test_door_lock(hass: HomeAssistant):
2828 assert lock ._data == {}
2929 await lock .async_hard_refresh_codes ()
3030 assert lock ._data == {}
31+ # we should not be able to clear a usercode that does not exist
3132 with pytest .raises (HomeAssistantError ):
3233 await lock .async_clear_usercode (1 )
33- assert lock .usercode_scan_interval == timedelta (minutes = 1 )
34+
35+ # we should be able to set a usercode and see it in the data
3436 await lock .async_set_usercode (1 , 1 , "test" )
3537 assert lock ._data ["1" ] == {"code" : 1 , "name" : "test" }
3638 await lock .async_get_usercodes ()
3739 assert lock ._data ["1" ] == {"code" : 1 , "name" : "test" }
3840
41+ # if we unload without removing permanently, the data should be saved
3942 assert await lock .async_unload (False ) is None
4043 assert await lock .async_setup () is None
4144 assert lock ._data ["1" ] == {"code" : 1 , "name" : "test" }
4245
46+ # we can clear a valid usercode
4347 await lock .async_set_usercode (2 , 2 , "test2" )
4448 assert lock ._data ["2" ] == {"code" : 2 , "name" : "test2" }
4549 await lock .async_clear_usercode (2 )
4650 assert "2" not in lock ._data
4751
52+ # if we unload with removing permanently, the data should be removed
4853 assert await lock .async_unload (True ) is None
4954 assert await lock .async_setup () is None
5055 assert not lock ._data
0 commit comments