File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ def ensure_unlocked_for_opener():
138138 lock = TemporarilyUnlocked (since = i .current_time , until = i .current_time + temp_unlock_time )
139139
140140 # unlock switch
141- if i .holdopen_button == True :
141+ if i .holdopen_button == True and lock . state != 'Unlocked' :
142142 lock = Unlocked (since = i .current_time , reason = 'switch' )
143143 elif i .holdopen_button == False and lock .state == 'Unlocked' and lock .reason == 'switch' :
144144 lock = Locked (since = i .current_time , reason = 'switch' )
Original file line number Diff line number Diff line change @@ -167,6 +167,27 @@ def test_dooropener_after_unlock():
167167 assert states .opener .state == 'TemporarilyActive'
168168
169169
170+ def test_holdopen_since_updates ():
171+ states = dlockoslo .States ()
172+ assert states .lock .state == 'Locked'
173+ assert states .opener .state == 'Inactive'
174+ inputs = dict (
175+ holdopen_button = True ,
176+ current_time = 100 ,
177+ )
178+ states = dlockoslo .next_state (states , dlockoslo .Inputs (** inputs ))
179+ assert states .lock .state == 'Unlocked' , 'unlocks'
180+ assert states .lock .since == 100 , 'update since on initial transition'
181+
182+ inputs = dict (
183+ holdopen_button = True ,
184+ current_time = 222 ,
185+ )
186+ states = dlockoslo .next_state (states , dlockoslo .Inputs (** inputs ))
187+ assert states .lock .state == 'Unlocked' , 'still unlocked'
188+ assert states .lock .since == 100 , 'dont update since when no state transition'
189+
190+
170191def test_bolt_present_reflects_input ():
171192 states = dlockoslo .States ()
172193 assert states .lock .state == 'Locked'
You can’t perform that action at this time.
0 commit comments