@@ -28,23 +28,28 @@ async def test_door_lock(hass: HomeAssistant):
28
28
assert lock ._data == {}
29
29
await lock .async_hard_refresh_codes ()
30
30
assert lock ._data == {}
31
+ # we should not be able to clear a usercode that does not exist
31
32
with pytest .raises (HomeAssistantError ):
32
33
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
34
36
await lock .async_set_usercode (1 , 1 , "test" )
35
37
assert lock ._data ["1" ] == {"code" : 1 , "name" : "test" }
36
38
await lock .async_get_usercodes ()
37
39
assert lock ._data ["1" ] == {"code" : 1 , "name" : "test" }
38
40
41
+ # if we unload without removing permanently, the data should be saved
39
42
assert await lock .async_unload (False ) is None
40
43
assert await lock .async_setup () is None
41
44
assert lock ._data ["1" ] == {"code" : 1 , "name" : "test" }
42
45
46
+ # we can clear a valid usercode
43
47
await lock .async_set_usercode (2 , 2 , "test2" )
44
48
assert lock ._data ["2" ] == {"code" : 2 , "name" : "test2" }
45
49
await lock .async_clear_usercode (2 )
46
50
assert "2" not in lock ._data
47
51
52
+ # if we unload with removing permanently, the data should be removed
48
53
assert await lock .async_unload (True ) is None
49
54
assert await lock .async_setup () is None
50
55
assert not lock ._data
0 commit comments