@@ -247,4 +247,36 @@ def test_bolt_present_periodic_update(bolt_present):
247247 assert states .bolt_present_updated > last_updated , 'should update'
248248 assert states .bolt_present_updated == 90.0
249249
250+ def test_state_change_identity ():
251+ states = dlockoslo .States ()
252+ change = dlockoslo .is_state_change (states , states )
253+ assert change == False
254+
255+ def test_state_change_equivalence ():
256+ state1 = dlockoslo .States ()
257+ state2 = dlockoslo .States ()
258+ change = dlockoslo .is_state_change (state1 , state2 )
259+ assert change == False
260+
261+ def test_state_change_only_since_until ():
262+ state1 = dlockoslo .States ()
263+ state2 = dlockoslo .States ()
264+ print (id (state1 ), id (state2 ))
265+ state2 .opener .since = 100
266+ state2 .opener .until = 110
267+ state2 .opener .since = 100
268+ state2 .opener .until = 110
269+
270+ change = dlockoslo .is_state_change (state1 , state2 )
271+ assert change == False , '.since and .until should be ignored'
272+
273+ def test_state_change_unlocking ():
274+ state1 = dlockoslo .States ()
275+ state1 .lock = dlockoslo .Locked (since = 10 )
276+ state2 = dlockoslo .States ()
277+ state2 .lock = dlockoslo .Unlocked (since = 20 )
278+
279+ change = dlockoslo .is_state_change (state1 , state2 )
280+ assert change == True , 'unlocking is state change'
281+
250282
0 commit comments