コード例 #1
0
def test_openbutton_inside_when_unlocked():
    states = dlockoslo.States(lock=dlockoslo.Unlocked(since=1))
    assert states.lock.state == 'Unlocked'
    inputs = dict(openbutton_inside=True, )
    states = dlockoslo.next_state(states, dlockoslo.Inputs(**inputs))
    # should just open, leave lock alone
    assert states.lock.state == 'Unlocked'
    assert states.opener.state == 'TemporarilyActive'
コード例 #2
0
def test_openbutton_outside_when_unlocked():
    states = dlockoslo.States(lock=dlockoslo.Unlocked(since=1))
    assert states.lock.state == 'Unlocked'
    inputs = dict(openbutton_outside=True, )
    states = dlockoslo.next_state(states, dlockoslo.Inputs(**inputs))
    # should _not unlock or open_ (user must open door using app first)
    assert states.lock.state == 'Unlocked'
    assert states.opener.state == 'TemporarilyActive'
コード例 #3
0
def test_mqtt_unlock_duration_when_unlocked():
    states = dlockoslo.States(lock=dlockoslo.Unlocked(since=1))
    inputs = dict(mqtt_request=('unlock', True), )
    states = dlockoslo.next_state(states, dlockoslo.Inputs(**inputs))
    # should not change state
    assert states.lock.state == 'Unlocked'
コード例 #4
0
def test_mqtt_lock():
    states = dlockoslo.States(lock=dlockoslo.Unlocked(since=1))
    inputs = dict(mqtt_request=('lock', True), )
    states = dlockoslo.next_state(states, dlockoslo.Inputs(**inputs))
    assert states.lock.state == 'Locked'